[英]Is System.Web.Helpers still required for MVC 5?
After an upgrade of an MVC 4
application to MVC 5
following the instruction given here , I get the following exception when I try to log in: 按照此处给出的说明将MVC 4
应用程序升级到MVC 5
后,尝试登录时出现以下异常:
Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
The source of the error is as follows: 错误的来源如下:
Line 77: public ActionResult Login(RegisterLoginModel model, string returnUrl)
Line 78: {
Line 79: if (ModelState.IsValid && WebSecurity.Login(model.Login.UserName, model.Login.Password, persistCookie: model.Login.RememberMe))
Line 80: {
Line 81: return Redirect(returnUrl);
Here is the assembly load trace: 这是程序集负载跟踪:
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/Users/Bruce/Documents/Projects/Pace/CourseChooser/trunk/CourseChooser.Web/
LOG: Initial PrivatePath = D:\Users\Bruce\Documents\Projects\Pace\CourseChooser\trunk\CourseChooser.Web\bin
Calling assembly : WebMatrix.WebData, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Users\Bruce\Documents\Projects\Pace\CourseChooser\trunk\CourseChooser.Web\web.config
LOG: Using host configuration file: D:\Users\Bruce\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
And here is the stack trace: 这是堆栈跟踪:
[FileNotFoundException: Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
WebMatrix.WebData.SimpleMembershipProvider.CheckPassword(IDatabase db, Int32 userId, String password) +0
WebMatrix.WebData.SimpleMembershipProvider.ValidateUser(String username, String password) +171
System.Web.Security.Membership.ValidateUser(String username, String password) +26
WebMatrix.WebData.WebSecurity.Login(String userName, String password, Boolean persistCookie) +42
Selector.Controllers.AccountController.Login(RegisterLoginModel model, String returnUrl) in D:\Users\Bruce\Documents\Projects\Pace\CourseChooser\trunk\CourseChooser.Web\Controllers\Account\AccountController.cs:79
lambda_method(Closure , ControllerBase , Object[] ) +146
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +30
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +197
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +46
System.Web.Mvc.Async.ActionInvocation.InvokeSynchronousActionMethod() +37
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +24
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +43
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +69
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +42
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +124
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +26
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +40
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +24
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +29
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9744373
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Can anyone help identify the problem here and how I can go about resolving it? 谁能在这里帮助您确定问题以及我该如何解决?
UPDATE: 更新:
I ran the following in NuGet Package Manager Console
: 我在NuGet Package Manager Console
运行以下命令:
update-package -reinstall
After running this a reference to System.Web.Helpers
was added back to my project references, this despite the fact that the guide referenced above says that this has been rebranded and should be removed. 运行此命令后,将对System.Web.Helpers
的引用添加回我的项目引用中,尽管以上引用的指南指出已对其进行了更名并应将其删除。 With System.Web.Helpers
back in the references the project now runs correctly. 有了System.Web.Helpers
的引用,该项目现在可以正确运行。 So the question now is: Is a reference to System.Web.Helpers
still required after updating to MVC 5, and if the answer is "No", then why is my project still requiring this reference? 因此,现在的问题是:在更新到MVC 5之后是否仍然需要引用System.Web.Helpers
,并且如果回答为“否”,那么为什么我的项目仍需要该引用?
No, it is not generally required. 不,通常不需要。
Your project still requires the reference because you are using WebMatrix.WebData
(specifically in your snippet, WebSecurity.Login
), which has a dependency on System.Web.Helpers
. 您的项目仍然需要引用,因为您正在使用WebMatrix.WebData
(特别是在代码段WebSecurity.Login
),它依赖于System.Web.Helpers
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.