簡體   English   中英

使用成員資格類登錄asp.net網站時出錯

[英]Error in login to asp.net web site using membership class

我已經使用asp.net mvc3編寫了一個網站,並使用Membership類進行用戶管理。
在VS2010中的localhost服務器上,一切正常,但是當我將其部署到服務器時,出現以下錯誤:

    Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 7/23/2011 3:30:31 PM 
Event time (UTC): 7/23/2011 10:30:31 PM 
Event ID: 5afe87171ad743d39bf87e29f8501615 
Event sequence: 7785 
Event occurrence: 49 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/3/ROOT-3-129559136991646761 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\wwwroot\bandarMVC\ 
    Machine name: BANDARPAYANE 

Process information: 
    Process ID: 2612 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\MVC 

Exception information: 
    Exception type: IndexOutOfRangeException 
    Exception message: Index was outside the bounds of the array.
   at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
   at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i)
   at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
   at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
   at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
   at BandarMVC.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in C:\Users\Javad\Documents\Visual Studio 2010\Projects\BandarMVC\BandarMVC\Controllers\AccountController.cs:line 40
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Request information: 
    Request URL: http://10.1.1.90/Account/LogOn?ReturnUrl=/ 
    Request path: /Account/LogOn 
    User host address: 10.1.1.90 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\MVC 

Thread information: 
    Thread ID: 26 
    Thread account name: IIS APPPOOL\MVC 
    Is impersonating: False 
    Stack trace:    at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
   at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i)
   at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
   at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
   at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
   at BandarMVC.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in C:\Users\Javad\Documents\Visual Studio 2010\Projects\BandarMVC\BandarMVC\Controllers\AccountController.cs:line 40
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Custom event details: 


有誰知道這個錯誤的原因和解決方案?

以下代碼引發此異常:

[HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
        BuildMenu();
        if (ModelState.IsValid)
        {
    ------->  if (Membership.ValidateUser(model.UserName, model.Password))   <----------------
            {

                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                ModelState.AddModelError("", "نام کاربر و یا شناسه عبور صحیح نمی باشد");
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

看起來好像是使用某些舊版本的.NET Framework aspnet_regsql.exe實用工具創建的應用程序部署時連接的數據庫。 嘗試使用與本地使用的相同版本的aspnet_regsql 創建和配置成員資格數據庫 或者在本地,您僅使用了SQL Express和~/App_Data文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM