aknuds1
aknuds1

Reputation: 68067

ASP.NET MVC 3 - Authorization of Windows users is slow, can we speed it up?

Our ASP.NET MVC 3 intranet application makes use of Windows user authentication, and also demands that users are in a certain role to access administrative sections (authorization). While all this works, we find that checking a user's role membership is really slow (~20 seconds). We use either the User.IsInRole method or AuthorizeAttribute. Even if we check against the local Administrators group ('BUILTIN\Administrators') instead of an AD group it's still as slow.

Now, is there some recommended scheme we may follow in order to speed up user authorization? Is it common for instance to cache a user's authorization status in a database? Is there, more fundamentally, something fishy going on since authorizing against a local group ('Administrators') is this slow?

EDIT:

The Web server is running on Windows 2008 R2 SP1 x64, .NET 4.0, IIS 7.5, 4 GB RAM. I am getting the same latency querying for the user role membership on my development machine however, so it looks like the issue is independent of the machine the app is running on. DBMS shouldn't matter I think, as the time is spent querying whether the user is a member of 'BUILTIN\Administrators' (to simplify the problem, I'm just checking this local group).

Upvotes: 2

Views: 1686

Answers (1)

RickAndMSFT
RickAndMSFT

Reputation: 22810

Under the hood ASP.NET MVC Windows user authentication is doing the same thing Web Forms does. I don't know of any performance problems using the frameworks MembershipProvider and RoleProvider with Web Forms or MVC. To debug this I'd create the simplest Web Forms (and MVC) projects and find out where all the time is spent. It could be your AD server is slow or that the first attempt to authenticate is timing out.

Upvotes: 1

Related Questions