奇怪的错误失败的ASP.Net登录
我有一个ASP.Net 3.5(C#)Web应用程序,它使用Sql Server 2008作为其数据库。 在那个数据库是一个标准的用户表与列用户名/密码,我有一个简单的登录表单来验证用户。 登录页面简单地查询表格,以查找与输入的值相匹配的用户名/密码组合。 如果用户输入一个有效的用户名/密码,它可以正常工作并继续进行,但是如果出于某种原因无效的组合出现错误而不是简单地找不到匹配项。 错误是:
System.Web消息:引发类型'System.Web.HttpUnhandledException'的异常。 堆栈跟踪:在System.Web.UI.Page.HandleError(例外五)在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)在System.Web.UI.Page.ProcessRequest(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint )在System.Web.UI.Page.ProcessRequest(HttpContext上下文)的System.Web.UI.Page.ProcessRequest()处,在c: Windows Microsoft.NET Framework64 v2中的ASP.login_aspx.ProcessRequest(HttpContext上下文) .0.50727 临时ASP.NET文件根 55c40ade 918a8ce7 App_Web_xyhtxem7.17.cs:行0在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()在System.Web.HttpApplication。 ExecuteStep(IExecutionStep步骤,布尔&完成同步)完整的错误文本:System.Web.HttpUnhandledException:引发类型'System.Web.HttpUnhandledException'的异常。 ---> System.Data.SqlClient.SqlException:由于无法启动用户实例的进程而无法生成SQL Server的用户实例。 连接将被关闭。 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection)在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)在System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream ,系统上的System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,Boolean ignoreSniOpenTimeout,Int64 timerExpire,SqlConnection owningObject)上的System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)处的BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)。 Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(字符串主机,字符串NEWPASSWORD,布尔redirectedUserInstance,SqlConnection的owningObject,SqlConnectionString connectionOptions,Int64的timerStart)在System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection的owningObject,SqlConnectionString connectionOptions,STR 在System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,Object providerInfo,String newPassword,SqlConnection owningObject,Boolean redirectedUserInstance)对象poolGroupProviderInfo,DbConnectionPool池,DbConnection拥有连接)在System.Data.ProviderBase上System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection拥有连接,DbConnectionPool池,DbConnectionOptions选项)在System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection拥有对象)。 DbConnectionPool.UserCreateRequest(的DbConnection owningObject)在System.Data.ProviderBase.DbConnectionPool.GetConnection(的DbConnection owningObject)在System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection owningConnection)在System.Data.ProviderBase.DbConnec tionClosed.OpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory的)在System.Data.SqlClient.SqlConnection.Open()在System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext的上下文中,布尔revertImpersonate)在System.Web.DataAccess.SqlConnectionHelper.GetConnection( String和passwordFormat,String和passwordSalt,Int32和failedPasswordAttemptCount,Int32和failedPasswordAnswerAttemptCount,Boolean和isApproved,DateTime和lastLoginDate,DateTime和lastActivityDate) System.Web.Security.SqlMembershipProvider.ValidateUser(String username,String password)在System.Web.Security.SqlMembershipProvider.CheckPassword(String username,String password,Boolean updateLastLoginActivityDate,Boolean failIfNotApproved,String&salt,Int32&passwordFormat) 在System.Web.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e)在System.Web.UI.WebControls.Login.AttemptLogin()System.Web.UI.WebControls.Login.OnBubbleEvent(Object source,EventArgs e)。 UI.Control.RaiseBubbleEvent(对象源,EventArgs的参数)在System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,字符串eventArgument)在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)---完内部异常堆栈跟踪---在System.Web.UI.Page.HandleError(异常e)在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)System.Web.UI.Page.ProcessRequest(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)在System.Web.UI.Page.ProcessRequest(HttpContext上下文)在ASP.login_aspx.ProcessRequest(HttpContext上下文)在c: Windows Microsoft System.Web.UI.Page.ProcessRequest()。 NE T Framework64 v2.0.50727 Temporary ASP.NET Files root 55c40ade 918a8ce7 App_Web_xyhtxem7.17.cs:System.Web.HttpApplication上的第0行
有什么想法发生了什么?
如果你不匹配sql的结果可能是NULL。 所以你没有得到任何有效的方法结果。 如果你做这样的事情
SELECT * FROM xxx WHERE username = {0} and password = {1}
尝试
SELECT COUNT(*) FROM xxx WHERE username = {0} and password = {1}
那么你得到和int值0或> 0返回验证。 但向我们展示帮助更多指定的代码。
这是一个猜测,因为你没有给出足够的信息来确定。
这听起来像是你写了自己的提供者,或者试图以某种方式绕过它。
如果您未能登录,它看起来像代码自动回落到默认提供程序,您仍然在web.config中有连接字符串。 可能是Visual Studio'有用'添加的默认连接字符串。 这是一个mdf,这是它在mdf不存在时抛出的错误。
该数据库显然不存在,并且由于该错误而失败。
因此,您可能需要在web.config中删除提供程序,或修复自己的提供程序或修复验证用户的方式。
您正在使用成员资格提供程序试图连接到SQL服务器 - 我想最可能你正试图通过提供数据库文件名来使用本地sql express实例。
在这种情况下,提供程序会尝试创建数据库,如果该数据库不存在,并且该帐户(在您的代码运行时)可能需要对该文件夹具有读/写权限。 或者你甚至可能没有在你的机器上安装sqlexpress。
我建议你检查连接字符串并尝试从那里调试 - 例如,尝试连接到该数据库(远程/本地)或创建该数据库(以及所需的模式)(如果不存在)。 将连接字符串更改为常规字符串(而不是提供文件名)等等...
有关创建成员资格提供程序所需的数据库和模式的更多帮助,请参见本文:http://www.asp.net/web-forms/tutorials/security/membership/creating-the-membership-schema-in-sql-server -CS
链接地址: http://www.djcxy.com/p/56693.html上一篇: Strange Error On Failed ASP.Net Login
下一篇: SQL Server login problem for a windows service on reboot
