2014-12-03 105 views
0

大家好,我正在管理一个用asp.net mvc4编写的网站。不过,我对我想发布的布局和CSS样式进行了一些更改,以更新当前网站。发布之前一切工作正常,当我在发布的过程中,我确保我没有触摸web.config文件,我只检查了我想更新的文件,这主要是一个Html和CSS的变化。发布网站后出现错误

发布后,我试图登录,我开始一个错误说

Error 
An error occurred while processing your request. 

请帮助我。我可以提供其他任何可以帮助我解决此问题的信息。

,当我试图在一个我对我的本地主机我得到这个错误

You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site. 

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.InvalidOperationException: You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site. 

Source Error: 


Line 36:   public ActionResult Login(LoginModel model, string returnUrl) 
Line 37:   { 
Line 38:    if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) 
Line 39:    { 
Line 40:     //return RedirectToLocal(returnUrl); 

Source File: c:\Users\IBN HAMZA\Documents\Visual Studio 2012\Projects\Zedvance\Zedvance\Controllers\AccountController.cs Line: 38 

Stack Trace: 


[InvalidOperationException: You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.] 
    WebMatrix.WebData.SimpleMembershipProvider.VerifyInitialized() +50 
    WebMatrix.WebData.WebSecurity.VerifyProvider() +36 
    WebMatrix.WebData.WebSecurity.Login(String userName, String password, Boolean persistCookie) +14 
    Zedvance.Controllers.AccountController.Login(LoginModel model, String returnUrl) in c:\Users\IBN HAMZA\Documents\Visual Studio 2012\Projects\Zedvance\Zedvance\Controllers\AccountController.cs:38 
    lambda_method(Closure , ControllerBase , Object[]) +147 
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +182 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 
    System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 
    System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58 
    System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225 
    System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225 
    System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 
    System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24 
    System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 
    System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14 
    System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55 
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 
    System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55 
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29 
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 
    System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25 
    System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 
+1

集'通过在你的web.config'检查完整的错误 – 2014-12-03 11:58:20

+0

@Vsevolod我应该做的活网站或我的本地主机? – ibnhamza 2014-12-03 12:00:59

+0

如果它在您的本地主机网站上运行,并且不在您的现场网站上,则在那里执行。如果它不能在你的本地站点上运行,那么你应该得到YSOD,或者在你的VS – 2014-12-03 12:09:10

回答

0

看到你所得到的错误后,这个问题似乎是事实,你叫WebSecurity初始化连接之前。

编辑抛出这样的错误文件:

public ActionResult Login(LoginModel model, string returnUrl) 
{ 
    if (!WebSecurity.Initialized) 
    { 
     WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); 
    } 
+0

对不起,我不明白“修复它的唯一方法的确是重新部署整个网站,除非你的web.config文件是例外。不会影响数据库? – ibnhamza 2014-12-03 12:17:33

+0

您的数据库不在远程位置吗?像SQL Server一样? – 2014-12-03 12:18:37

+0

检查我更新的答案。 – 2014-12-03 12:22:42