ASP MVC授权错误 [英] ASP MVC Authorize Error
问题描述
当我使用:
[授权]
公众的ActionResult指数(){
....
返回查看();
}
或
[授权(用户=约翰)]
公众的ActionResult指数(){
....
返回查看();
}
我的脚本工作井但是当我使用:
[授权(角色=管理员)]
公众的ActionResult指数(){
.....
返回查看();
}
错误:
发生-特定实例的网络相关的或错误而
与SQL Server建立连接。服务器没有被发现或
无法访问。验证实例名称是否正确,以及
SQL Server配置为允许远程连接。 (提供者:SQL
网络接口,错误:26 - 错误定位服务器/实例
指定)。
块引用>解决方案我找到了解决办法。在我的web.config:
1<模块>
2.<清除NAME =FormsAuthenticationModule/>
3.<清除NAME =RoleManager/>
4.< /模块>我加了3号线,新AspNet.Identity code接手允许我使用User.IsInRole(..)
When I Use :
[Authorize] public ActionResult Index() { .... return View(); }
OR
[Authorize(Users="john")] public ActionResult Index() { .... return View(); }
My Script Working Well But When I Use :
[Authorize(Roles="Admin")] public ActionResult Index() { ..... return View(); }
Error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).
解决方案I found a solution. In my web.config:
1.<modules> 2.<remove name="FormsAuthenticationModule" /> 3.<remove name="RoleManager" /> 4.</modules>
I added the line 3, and the new AspNet.Identity code took over allowing me to use User.IsInRole(..)
这篇关于ASP MVC授权错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!