Visual Studio调试对外部数据库的访问 [英] Visual studio debug access to external database

查看:74
本文介绍了Visual Studio调试对外部数据库的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对用于Web API的Visual Studio 2013调试模拟器的工作方式有疑问.

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

我已经在Visual Studio 2013中构建了一个Web API项目,以访问外部服务器上的数据库.该代码是使用VS2013的ASP.NET Web应用程序项目模板为Web API应用程序构建的.构建完成后,运行调试将打开本地主机端口56618的浏览器窗口,该窗口允许Fiddler进行访问以测试Http请求.

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.

项目完成后,我使用Web Deploy to IIS将其发布到网站上.但是,尽管该页面将打开(现在位于localhost:9812),但是一个http请求将引发内部服务器错误500.

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.

细读IIS FailedReqLogFiles,我注意到失败的原因是数据库服务器拒绝访问'< Domain> \<计算机名> $'.

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>$'.

我在具有读取和写入特权的sql实例上添加了< Domain> \<计算机名称> $"作为有效登录名(Windows身份验证,因为连接字符串包括"Integrated Security = true"),并且问题已解决.

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.

问题是,为什么Visual Studio调试模拟器没有相同的问题?

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

推荐答案

因为模拟器是在您自己的帐户(例如< Domain> \ You )的上下文中运行网站.您的帐户可以访问数据库,所以没有问题.

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.

当您将其发布到IIS时,它开始在另一个帐户(< Domain> \ Machine-Name )的上下文中运行-但根据IIS的配置方式还有其他变体,并且IIS版本),该版本无权访问您的数据库.

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.

这篇关于Visual Studio调试对外部数据库的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆