0

What I want to do is to make an ActionLink visible in my page only to certain roles(in this case the "Admin" role).

When I add this code to my Layout page...

@if (Request.IsAuthenticated)
{
    if (HttpContext.Current.User.IsInRole("Admin"))
    {
        <li>@Html.ActionLink("Select Roles", "Index", "SelectRoles")</li>
    }
}

The following SQL Server error shows up:

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)

What seems to be the problem? I observed that I cannot use classes like Membership, Roles or attributes like Authorize because the same problem appears .

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Stefan P.
  • 331
  • 6
  • 23

1 Answers1

0

That is a pure Sql connection error, this error has nothing to do with the any roles. Check if by instance you have more than one connection string in your solution, that might be an explanation to why your connection works sometimes and sometimes not.

mohamed_assem
  • 123
  • 1
  • 2
  • 9