0

I have a question as to how the Visual Studio 2013 debug emulator for Web API works.

I had built a Web API project in Visual Studio 2013 to access a database on an external server. The code was built using VS2013's ASP.NET Web Application project template for a Web API application. Once built, running debug opened a browser window for localhost port 56618, which allowed access from Fiddler to test Http requests.

Once I had the project finished, I published it to a website using Web Deploy to IIS. However, whilst the page would open (now at localhost:9812), an http request would throw an Internal Server Error 500.

Perusing the IIS FailedReqLogFiles, I noticed that the reason that it was failing was that the database server was refusing access to '<Domain>\<machine-name>$'.

I added '<Domain>\<machine-name>$' as a valid login (windows authentication, as the connection string included "Integrated Security=true") on the sql instance with read and write privileges, and the problem was resolved.

The question is, why didn't the Visual Studio debug emulator have the same issue?

BM-
  • 616
  • 5
  • 15

1 Answers1

1

Because the emulator was running the website under the context of your own account (e.g. <Domain>\You). Your account had access to the database, so there was no issue.

When you published it to IIS, it started running under the context of a different account (<Domain>\Machine-Name - but there are other variants depending on how IIS is configured, and the version of IIS), which didn't have access to your database.

Brendan Green
  • 11,676
  • 5
  • 44
  • 76