I've run into a bit of a biff baff, using this new asp membership thingy on mvc5
I'm trying to determine what role a user is in and then, provided the role condition is met, show a button. I've got the code for the button hooked up as follows:
<p>
@if(User.IsInRole("canEdit"))
{
@Html.ActionLink("Create New", "Create")
}
</p>
Nice and simple, show the create button if user is in 'canEdit' role, right?... Wrong...
When i put this into my razor (chstml or whatever it is). file and load the page I get the following sql related 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)
Some things to note:
I have one dbcontext which has the following code:
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();
}
The props have been removed for brevity.
-I have one connection string in the config file. -I can register, login logout, delete, use the isAuthenticated method ect.
I am truly baffled, any pointers on this would be great