I just published my new ASP.NET MVC web site with Identity and OWIN authorization on Azure. Front-end works great, but got a problem with back-end. I use [Authorize] attribute with my admin controllers to check if user has a required role to access it, like this:
[Authorize(Roles = "Admin")]
On localhost even when using remote Azure SQL database it works fine. But on Azure, any controller with authorize attribute with roles loading several minutes and then throws:
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)
Authorize attribute without roles works fine.
Adding this code to the web.config fixes the issue.
<system.webServer>
<modules>
<remove name="RoleManager" />
</modules>
</system.webServer>
I know this is late now but I have a real answer for you. Thought I'd share it anyway as I just wasted a few hours on it myself.
Info found from this post
Didn't really solve the Azure problem, ended up writing my own Authorization attribute. The problem seems to be in User.IsInRole()
method, so just avoid it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With