poosiang
poosiang

Reputation: 3

Database issues with regards to deploying MVC application

Platform: Windows 7 with VS2013, Microsoft Server 2008 R2 and Microsoft SQL Server 2012.

Good Day to All.

My partner and I recently created an MVC application which works in localhost with a local database hosted in Microsoft SQL Server 2012 within the computer.

But now what we would like to do is to host this application on a website for our users to use the application.
Hosting has been done, where we managed to get the front page to show, but the issue lies with database connection to the MS SQL Server 2012 within the server.

When we check our SQL error log we see this:
2015-05-26 12:04:38.26 Logon Error: 18456, Severity: 14, State: 38.
2015-05-26 12:04:38.26 Logon Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database 'HRMS.Models.EmployeeDBContext'. [CLIENT: <local machine>] May I seek some advice as to how we can set up the MVC application on the server to talk to the MS SQL 2012 installed within the server?

We're both new to MVC and ASP.Net, Please guide us in the simplest way possible.

Thanks in advance!

Upvotes: 0

Views: 268

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48230

Your connection string most probably indicates an integrated authentication (integrated security=true) which means that the identity of the worker process is trying to connect to the database.

The problem is that you haven't set the identity in an explicit way or rather you set it to the Network Service built-in account.

And this account is not listed as permitted to access the database.

You have two options:

  1. add permissions to the Network Service to access the database (not recommended)

  2. create a separate identity (user) in the server's operating system (or a domain account if you have a catalog) and both assign the identity to the application pool in IIS (so that the ASP.NET process is run under this account) and give this user permissions to access the database.

More on that here:

http://www.iis.net/learn/manage/configuring-security/application-pool-identities

Upvotes: 2

Related Questions