asp.net mvc - How to achieve Login authentication without memebership in MVC 4 -
In MVC 4, I've added authentication manually, I mean, no subscription stuff.
Take this username and password, justify it against the database.
Now, how do I allow a valid (authenticated) user to interact with other controllers because I've added authorized
annotations to all other controllers and to limit Only authenticated users should have permission to use other controller's action method. Please guide me how I can get it as a way to subscribe I received?
Thanks
The only way to write your own custom authorization attribute: < / P>
public class CustomAuthorizeAttribute: AuthorizeAttribute {entities reference = new entities (); // My organization private readonly string [] approved; Public CustomAuthorizeAttribute (parameter string [] roles) {this.allowedroles = roles; } Secure Override bool AuthorizeCore (HttpContextBase httpContext) {bool authorize = false; (Different roles in the above permissions) {var user = context.Epuser Where (M => M. UserID == GetUser.CurrentUser / * User Form is Receiving Current Reference / / & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp ;.MM; Role == Role & amp; Amp; m.IsActive == True ); // Check active users with allowed roles. If (user.Count ()> 0) {authorize = true; / * True if the unit has the current user (active) with a specific role, then that is correct; Return authorization; } Protected Override Zero Handel Indexed Request (Authority Resource Filter Filter) {filterContext.Result = New HttpUnauthorizedResult (); }}
and then use it:
[CustomAuthorize ("Administrator") Public ActionResult SomeAction () {return View (); }
see
or you can write custom action filter attributes, see
another method I implemented recently It was defined as its own base controller and the successor to that of the other controllers:
Comments
Post a Comment