我得到这个错误请告诉我如何解决它。当我通过Vs 2010主持它时,应用程序正常工作但是我通过Iis.Wwwwebroot主持它时遇到这个错误 [英] I M Getting This Error Kindly Tell Me How Can I Resolve It.Application Is Working Fine When I M Hosting It Through Vs 2010 But This Error I Am Getting When Hosting It Through Iis.Wwwwebroot

查看:75
本文介绍了我得到这个错误请告诉我如何解决它。当我通过Vs 2010主持它时,应用程序正常工作但是我通过Iis.Wwwwebroot主持它时遇到这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quote:

无法打开登录请求的数据库ankur。登录失败。

用户'IIS APPPOOL \DefaultAppPool'登录失败。

描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的起源的更多信息。



异常详细信息:System.Data.SqlClient.SqlException:无法打开数据库 ankur登录请求。登录失败。

用户'IIS APPPOOL \DefaultAppPool'登录失败。



来源错误:





第19行:myadp.SelectCommand = new SqlCommand();

第20行:myadp.SelectCommand.Connection = con;

第21行:con.Open();

第22行:myadp.SelectCommand.CommandText =select * from user1 where user1 = @ un and password1 = @ ps;

第23行:myadp.SelectCommand.Parameters.AddWithValue(@ un,TextBox1.Text);

Cannot open database "ankur" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
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: Cannot open database "ankur" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

Source Error:


Line 19: myadp.SelectCommand = new SqlCommand();
Line 20: myadp.SelectCommand.Connection = con;
Line 21: con.Open();
Line 22: myadp.SelectCommand.CommandText = "select * from user1 where user1=@un and password1=@ps";
Line 23: myadp.SelectCommand.Parameters.AddWithValue("@un", TextBox1.Text);

推荐答案

你的连接字符串有问题,您正在尝试从应用程序托管系统访问您的数据库,并且从该系统无法访问您的数据库,这就是您收到此错误的原因。
检查连接字符串是否对连接字符串进行了适当的更改并确保您的数据库可通过托管系统访问。
Your connection string has problem, you are trying to access your database from application hosting system and from that system your database is not accessible that's why you got this error.
Check you connection string make appropriate changes to connection string and also make sure that your database is accessible over your hosted system.


这是什么告诉您,您已在数据库连接字符串中集成了安全性集。这意味着应用程序将尝试根据Web服务器上用户的身份进行连接。现在,您的网站在一个应用程序池中运行,该应用程序池的用户设置为IIS_APPPOOL \DefaultAppPool。您需要将应用程序池设置为在数据库中作为安全的低权限用户运行,或者您需要更改连接字符串以作为安全的低权限命名用户运行。在任何一种情况下,您都必须确保已在数据库中设置此用户。良好的安全性实践要求您在操作系统和数据库级别为该用户分配尽可能低的权限。
What this is telling you is that you have integrated security set in your database connection string. This means that the application will attempt to connect based on the identity of the user on the web server. Now, your website is running inside an application pool that has a user set to IIS_APPPOOL\DefaultAppPool. You either need to set your application pool to run as a secure, low privilege user in the database, or you need to change your connection string to run as a secure, low privilege named user. In either case, you must ensure that you have setup this user in the database. Good security practice dictates that you allocate the lowest possible privileges for this user both at the operating system and the database levels.


这篇关于我得到这个错误请告诉我如何解决它。当我通过Vs 2010主持它时,应用程序正常工作但是我通过Iis.Wwwwebroot主持它时遇到这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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