我的MVC4应用程序中有关于webSecurity的错误。 [英] I got a error in my MVC4 application regarding webSecurity.
本文介绍了我的MVC4应用程序中有关于webSecurity的错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下......
public ActionResult Login(用户模型, string returnUrl = / Home)
{
if (ModelState.IsValid&& WebSecurity.Login(model.UserFirstName,model.Password))
{
return RedirectToLocal(returnUrl);
}
// 如果我们到目前为止,有些事情失败,重新显示表格
ModelState.AddModelError( , 提供的用户名或密码不正确。);
return 查看(模型);
}
错误是..
在调用WebSecurity类的任何其他方法之前,必须调用WebSecurity.InitializeDatabaseConnection方法。此调用应放在站点根目录中的_AppStart.cshtml文件中。
解决方案
尝试下面建议的解决方案。 />
http://www.whatibroke.com/?p=882 [ ^ ]
http:// stackoverflow.com/questions/17839032/you-must-call-the-websecurity-initializedatabaseconnection-method-before-you-c [ ^ ]
使用[在控制器名称上方的InitializeSimplemembership]意味着
[InitializeSimplemembership]
///这里你的控制器启动
My Code is bellow....
public ActionResult Login(user model, string returnUrl="/Home")
{
if (ModelState.IsValid && WebSecurity.Login(model.UserFirstName, model.Password))
{
return RedirectToLocal(returnUrl);
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
And error is..
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.
解决方案
try the solution suggested below.
http://www.whatibroke.com/?p=882[^]
http://stackoverflow.com/questions/17839032/you-must-call-the-websecurity-initializedatabaseconnection-method-before-you-c[^]
Use [InitializeSimplemembership] above the controllername means
[InitializeSimplemembership]
/// Here your controller starts
这篇关于我的MVC4应用程序中有关于webSecurity的错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文