【发布时间】:2014-06-01 10:56:39
【问题描述】:
我在 mvc5 上使用这个新的 asp 成员资格时遇到了一些麻烦
我正在尝试确定用户的角色,然后在满足角色条件的情况下显示一个按钮。 我将按钮的代码连接如下:
<p>
@if(User.IsInRole("canEdit"))
{
@Html.ActionLink("Create New", "Create")
}
</p>
简单明了,如果用户处于“canEdit”角色,则显示创建按钮,对吗?...错误...
当我把它放入我的剃须刀(chstml 或其他任何东西)时。文件并加载页面我得到以下 sql 相关错误:
发生网络相关或特定于实例的错误,同时 建立与 SQL Server 的连接。找不到服务器或 无法访问。验证实例名称是否正确,并且 SQL Server 配置为允许远程连接。 (提供者:SQL 网络接口,错误:26 - 定位服务器/实例时出错 指定)
注意事项:
我有一个具有以下代码的 dbcontext:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
}
public class GameContext : IdentityDbContext<ApplicationUser>
{
public GameContext() : base("DefaultConnection", throwIfV1Schema: false)
{
}
public static GameContext Create()
{
return new GameContext();
}
为简洁起见,这些道具已被删除。
-我在配置文件中有一个连接字符串。 -我可以注册,登录注销,删除,使用isAuthenticated方法等。
我真的很困惑,任何关于这个的指针都会很棒
【问题讨论】:
标签: c# asp.net asp.net-mvc entity-framework razor