Asp.net - 当我在 IIS 上运行网站时,数据库登录失败
在我的网站中,我使用“Windows 身份验证模式”访问我的 sqlserver 数据库。 当我使用 Visual Studio 运行我的网站时,一切正常。 但是当我在 IIS 上托管我的网站时,每次都会出现“数据库登录失败”的错误消息。
用户“HAL\IUSR_HAL”登录失败。(HAL 是我的网络服务器的名称)
我是否应该对数据库属性进行一些修改,以便可以通过 IIS 登录数据库?
In my website I am accessing my sqlserver database using "windows authencation mode".
Everything works fine when I run my website using visual studio.
but when I hosted my website on IIS, everytime an error message comes that "database login failed".
Login failed for user 'HAL\IUSR_HAL'.(HAL is the name of my webserver)
Should I do some modifications in database properties so that I can login to database through IIS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在 IIS 中使用匿名访问,则需要在连接字符串中提供有效 sql 用户的用户 ID 和密码。
If your using anonymous access in IIS you will need to supply a user id and password for a valid sql user in your connection string.
经过一番研究,我得到了这个问题的答案。
要通过IIS上运行的网站访问数据库,需要对IIS的IUSR帐户和ASPNET帐户进行身份验证并授权给sqlserver。
(ASPNET帐户是与IIS关联的dotnet框架帐户,用于处理asp.net页面。)
执行此操作:
打开Sqlserver Management Studio。
前往“安全”。
然后右键单击“登录”并选择“新登录”。
在登录名上按“搜索”。
然后单击“高级”按钮。
然后按“立即查找”按钮。
然后从出现的列表中选择上述两个帐户。(一次一个)
然后按确定。
选择登录名后,转到“用户映射”选项。
然后从那里选择数据库并检查所需的权限。
现在你已经完成了一切。按确定。
您可以从您的网站访问数据库。
After some research i got the answer of this question.
To access the database through a website running on IIS , IIS's IUSR account and ASPNET account should be authenticated and authorized to sqlserver.
(ASPNET account is the account of dotnet framework associated with IIS to process asp.net pages.)
to do this:
open Sqlserver management studio.
go to SECURITY.
then right click on LOGIN and select "new login".
press "search" on login name.
then click "advanced" button.
Then press "find now" button.
then from list appeared select both of the accounts mentioned above.(one at a time)
then press ok.
after selecting the login name go to it's "user mappings" options.
then select the database from there and check the desired permissions.
now you are done with everything. press ok.
you can access database from ur website.
在您的 web.config 文件中查找
并添加:
In your web.config file look for
and add:
查看以下链接:
http://msdn.microsoft.com/en- us/library/ms998292.aspx
希望这有帮助。
谢谢,
拉惹
Check out the following link:
http://msdn.microsoft.com/en-us/library/ms998292.aspx
Hope this helps.
Thanks,
Raja