Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

How to determine if user has access to controller method based on Auth attribute

$
0
0

I'm using Auth[] attributes on my controller methods to control access to those methods.  I would like to determine programmatically if a user has access to a method so that I can be proactive, rather than let mvc raise a login box when a user doesn't have access.  Although redirecting to the login page seems to make perfect sense, it doesn't make for very good usability to display a bunch of stuff the user doesn't have access to.

Is it possible to do something like this?

//this is pseudo code

If (user.HasAccess("some controller method")){

//do something

}

 

 


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>