Asp.net mvc site project works on local machine, but some parts do not work after publishing - asp.net-membership

My Asp.Net MVC project works on local machine without any problems. And, in my project, I use membership provider.
After I publish my site, some parts work correctly. However, membership system does not work. And error message is "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'."
My Connection String is like this;
<add name="ApplicationServices" connectionString="Data Source=111.111.111.111;Initial Catalog=DBname;Persist Security Info=True; User Id=123123;Password=pass;" providerName="System.Data.SqlClient" />
<add name="DATABASE" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=System.Data.SqlClient;provider connection string="data source=111.111.111.111;Initial Catalog=DBname; User Id=123123;Password=pass;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
user login and register functions , which uses "ApplicationServices", does not work.
But, other functions, which connect database with "DATABASE", works correctly.

You will need to allow the application to show you errors.
"Sorry, an error occurred while processing your request." is a default message.
In your web.config (Under system.web) add the following.
<customErrors mode="off" />
Then report back with the error message you receive.
======= In Response to the Edit
The error is simply telling you that you havent imported one of the stored procedures. Make sure you've exported it from local (Via Generate Scripts or Backup).

Related

IIS8.5 Windows authentication

I am trying to create a web application in my company and I want to get the username requesting the page to define what he/she can do. My environment is a Windows 2012 R2/IIS8.5. The server is in the corporative domain. What I have tried was to enable Windows Authentication and Disabling the anonymous authentication.
Here is the Web.config file with the set recommended.
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
...
</system.web>
Here is the Authentication configuration sets
My problem is that when I do any of the things above I get the Error 404.
If I let the Anonymous Login enabled and the Windows Authentication disabled and remove the Web.config settings the application works.
I need some help to guide on this. I tried to find a tutorial explaining how to do that but I could not find something that explain it clearly. I am starting using IIS.
EDIT1
I have enable the detail error pages and what I am getting is the error 404.15 (URL too long). It seams that it happening when I disable Anonymous Authentication in my application. Does anyone have faced this problem?
Thanks
I managed to solve it.
Originally I was creating the web application with .NET framework 4.5. When I changed it to 4.0 the windows authentication worked fine and I was able to get the logged user using User.Identity.Name.

Elmah mvc erases error logs after site restart

I have integrated Elmah.mvc via Nuget in my mvc application. It is storing logs properly but when i do any changes in web.config or restart the site all the error logs stored are erased. Is there a way to preserve its logs permanently in some location probably inside project folder or somewhere. Pls suggest.
Yes! All you have to do is tell Elmah to record logs in files instead of in memory, like this (in elmah's web.config session):
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
to save in memory it should be:
<errorLog type="Elmah.MemoryErrorLog, Elmah" size="1000"/>
Don't forget to allow write access on "logPath" folder.

How can I call one asmx but not another, in the same folder?

I have two web services, of old school, asmx. Both is in the same sub folder, which have anonymous authentication, in a MVC web application that have windows authentication.
When I browse one of them I get expected result, I can Invoke the service, but when I browse the other I get "HTTP Error 401.2 - Unauthorized You are not authorized to view this page due to invalid authentication headers.".
I then rename the second one and everything works fine. Even if I remove the second asmx file I get Unauthorized, instead of "Resource not found".
I have searched the registry and the file system for references to the file name, but find nothing. I deleted ASP.NET Temporary Files, but that did not help.
Any trouble shooting suggestions?
This was not easy to find, but in inetpub\temp\appPools\ there was a folder named as the application pool. In that folder there is "copy" of parts of the IIS config.
At some point we must have accidentally marked the actual asmx file, instead of the folder when we changed autentication. So it contained a special configuration section for just the file. Like:
<location path="Web/Services/ServiceName.asmx">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
When we removed that section it worked again :)

SQL Compact Edition - Access to the database file is not allowed

I am in the process of creating a blog site from scratch using MVC 3.0 and the Entity Framework. I am using a SQL CE .sdf file for the data store. This is stored in the projects App_Data folder. Locally, everything works fine. Not a problem. The .sdf file is read and processed without error. However, after using Web Deploy to publish to a shared hosting provider, I get the following error when trying to view the remote site:-
Access to the database file is not allowed
The connection string I am using in web config is:-
<connectionStrings>
<add name="DataAccess.BlogDbContext" connectionString="Data Source=DansMVCBlog.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
I have researched the problem and have hit a brick wall. Suggestions have included adding App_Data/DansMVCBlog.sdf to the connection string file path rather than just the file name. This does not work as you are advised the file path is invalid. On the shared hosting control panel, I have set read/write permissions on the App_Data folder to be true. Also, in my Global.asax file, I have disabled
`Database.SetInitializer(new DataInitializer());
Am I making a schoolboy error here? Does anyone have any suggestions? Thanks
Looks like the OP may have solved their problem but in my case, it turned out that the database file had been marked as Read Only by my source control system. Clearing the Read Only flag solved the problem.
You probably need to update your connection string
<connectionStrings>
<add name="DataAccess.BlogDbContext"
connectionString="Data Source=|DataDirectory|DansMVCBlog.sdf"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
Who knows what the solution to this was. All I can say is I was having problems publishing using web deploy, so I switched to using ftp. After that everything worked just fine.

Why EF is trying to create a database when i have already done that

The page in my application where database access is performed, I am getting an error which says
CREATE DATABASE permission denied in database 'master'.
Following is the url : http://price-tag.org/Store/Section/Computers.
I have created the database on hosting provider database server and following is my connectionstring
<add name="PriceCompareEntity" connectionString="Data
Source=rdinvent.db.8750445.hostedresource.com; Initial Catalog=rdinvent; User
ID=myDatabase; Password=myPassword;" providerName="System.Data.SqlClient" />
What can be the reason for this error? Also, why is it trying to recreate the database when I have already done that and there is no initialization for new database defined in Global.asax
Im assuming you are using EF CodeFirst? The reason this is happening is because you havent correctly passed the connection string settings into the CodeFirst Context object. This means its trying to create the ContextDB using the full name/namespace of the context.

Resources