I have published my Asp.Net MVC Application on IIS 7
Now when i run the application i get this error
Login failed for user 'mydomain\WEBSRVDV01$'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'mydomain\WEBSRVDV01$'.
Source Error:
Line 49: public ObjectResult<MigProcess> GetList()
Line 50: {
Line 51: return base.ExecuteFunction<MProcess>("GetList");
Line 52: }
Line 53: public ObjectResult<SummaryDetail> GetDetail(Nullable<long> summaryID)
Source File: E:\Applications\Project\Model\ProjectModel.Context.cs Line: 51
It looks like Asp.Net cann't connect to SQL Server, since I am connecting using
Windows Authentication
Asp.Net is trying to connect SQL using user mydomain\WEBSRVDV01$
where WEBSRVDV01 is my machine name where IIS is installed.
When i am running my Application from VS 2010 it is running fine. Only when i publish the site, i get this issue.
Using a Windows Authentication is not recommended as it poses your site to higher security risk. You are recommended to use SQL Server Authentication and you can do so by creating a separate db user for a particular database. To create a database user, you
can simply go to your Database -> Security -> User and please just make sure you grant a dbo_owner permission for this db user.
Next, you need to modify your web.config connection string to include:
SanjaySutar
Participant
1128 Points
696 Posts
sql server error after deployment
Apr 16, 2012 06:55 AM|LINK
Hi,
I have published my Asp.Net MVC Application on IIS 7
Now when i run the application i get this error
Login failed for user 'mydomain\WEBSRVDV01$'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'mydomain\WEBSRVDV01$'. Source Error: Line 49: public ObjectResult<MigProcess> GetList() Line 50: { Line 51: return base.ExecuteFunction<MProcess>("GetList"); Line 52: } Line 53: public ObjectResult<SummaryDetail> GetDetail(Nullable<long> summaryID) Source File: E:\Applications\Project\Model\ProjectModel.Context.cs Line: 51It looks like Asp.Net cann't connect to SQL Server, since I am connecting using Windows Authentication
Asp.Net is trying to connect SQL using user mydomain\WEBSRVDV01$ where WEBSRVDV01 is my machine name where IIS is installed.
When i am running my Application from VS 2010 it is running fine. Only when i publish the site, i get this issue.
Any help would be appreciated.
Thanks in advance.
mameenkhn
Contributor
2026 Points
391 Posts
Re: sql server error after deployment
Apr 16, 2012 07:10 AM|LINK
Put your connectionstring
--------------------------------------------------
Muhammad Amin
محمد امين
SanjaySutar
Participant
1128 Points
696 Posts
Re: sql server error after deployment
Apr 16, 2012 08:11 AM|LINK
Dino He - MS...
Star
8068 Points
1023 Posts
Microsoft
Re: sql server error after deployment
Apr 18, 2012 07:44 AM|LINK
Hi
You can try this:
1 Application pools-> asp.net v4.0->Advanced settings->Process model
2 under process model can the Identity to LocalSystem then it should work.
Hope it helpful.
Thanks
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
SanjaySutar
Participant
1128 Points
696 Posts
Re: sql server error after deployment
Apr 19, 2012 06:59 AM|LINK
HI Dino,
I tried this. It doesn't work. Probably because local account is not added to sql server user group.
As of now I fixed by impersonating it under specific domain account.
That worked for me.
necro_mancer
Star
8169 Points
1595 Posts
Re: sql server error after deployment
Apr 20, 2012 03:16 AM|LINK
hi sanjay,
Using a Windows Authentication is not recommended as it poses your site to higher security risk. You are recommended to use SQL Server Authentication and you can do so by creating a separate db user for a particular database. To create a database user, you can simply go to your Database -> Security -> User and please just make sure you grant a dbo_owner permission for this db user.
Next, you need to modify your web.config connection string to include:
<add name="connString" connectionString="Data Source=your_SQL_Server;uid=your_SQL_username;pwd=your_SQL_password;Initial Catalog=your_SQL_database_name" ></add>
Please mark this response as an "answer" if it helps you. Thanks heaps!
Professional SQL 2008 R2 Service