2011-07-24 42 views
0

我已經使用asp.net mvc3編寫了一個網站,並使用Membership類進行用戶管理。
一切工作在VS2010我的本地服務器上的罰款,但是當我部署到服務器我得到了下面的錯誤有時:使用會員類登錄到asp.net網站時出錯

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); 
    } 
+0

你能忍受拋出這個錯誤的代碼嗎? –

+0

我已更新問題並將代碼 – JGC

回答

1

看起來你正在連接,當你部署應用程序的數據庫是一些老版本的.NET Framework aspnet_regsql.exe實用的創建。試用creating and configuring the membership database與您在本地使用的相同版本aspnet_regsql。或者,也許在本地只需使用SQL Express和~/App_Data文件夾。

+0

我已在服務器和本地主機中使用.NET Framework v4.0.30319我使用SQLEXPRESS SERVER 2008 R2,但在本地主機SQLEXPRESS 2008.我應該怎麼做? 我必須強調,我很少得到這個錯誤。 – JGC

+0

比較兩個數據庫中的表結構。你想先比較一下aspnet_Membership表。 – Pleun

+0

他們是一樣的。 – JGC