Question

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).

Était-ce utile?

La solution

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(..)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top