use*_*804 7 asp.net-mvc asp.net-mvc-4 asp.net-mvc-5 asp.net-identity
当我使用时:
[Authorize]
public ActionResult Index() {
....
return View();
}
Run Code Online (Sandbox Code Playgroud)
要么
[Authorize(Users="john")]
public ActionResult Index() {
....
return View();
}
Run Code Online (Sandbox Code Playgroud)
我的脚本运行良好但我使用时:
[Authorize(Roles="Admin")]
public ActionResult Index() {
.....
return View();
}
Run Code Online (Sandbox Code Playgroud)
错误:
建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确,以及SQL Server是否配置为允许远程连接.(提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错).
小智 11
我找到了解决方案.在我的web.config中:
1.<modules>
2.<remove name="FormsAuthenticationModule" />
3.<remove name="RoleManager" />
4.</modules>
Run Code Online (Sandbox Code Playgroud)
我添加了第3行,新的AspNet.Identity代码接管了我的使用User.IsInRole(..)
| 归档时间: |
|
| 查看次数: |
1217 次 |
| 最近记录: |