【发布时间】:2014-10-28 20:40:26
【问题描述】:
我想要做的是让 ActionLink 在我的页面中仅对某些角色可见(在本例中为“管理员”角色)。
当我将此代码添加到我的布局页面时...
@if (Request.IsAuthenticated)
{
if (HttpContext.Current.User.IsInRole("Admin"))
{
<li>@Html.ActionLink("Select Roles", "Index", "SelectRoles")</li>
}
}
出现以下 SQL Server 错误:
与 SQL Server 建立连接时出现与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供者:SQL 网络接口,错误:26 - 错误定位服务器/指定实例)
似乎是什么问题?我观察到我不能使用诸如 Membership、Roles 之类的类或 Authorize 之类的属性,因为出现了同样的问题。
【问题讨论】:
-
确保您的连接字符串正确。
-
没错。我用它尝试了 EF,它成功了。
标签: sql-server asp.net-mvc asp.net-roles