c# - How to override Login logic in ASP.NET MVC 5? -


in past, used create custom membershipprovider communicate custom database or logic, this:

if (membership.validateuser(model.emailaddress, model.password)) {     (...) // validation logic     formsauthentication.redirectfromloginpage(model.emailaddress, false); } 

and authenticated user, mean: username displayed in top right corner, user can access [authorize] controller methods, etc.

when try approach in mvc 5, nothing happens , behaves user not authenticated.

how override authentication logic in asp.net mvc 5?

i call web api, service, etc. validate credentials , user authenticated having mentioned behaviour (the username displayed in top right corner, user can access [authorize] controller methods, etc) .

to have own authz need map authorizeattribute own customer authorization attribute. can achieve using unity this:

<alias alias="authorizeattribute" type="system.web.http.authorizeattribute, system.web.http" /> <alias alias="customauthorizationattribute" type="customsecurity.customauthorizationattribute, customsecurity" />  <register type="authorizeattribute" mapto="customauthorizationattribute" /> 

now when tries call controller actions has [authorize] attribute on them, customauthorizationattribute class called.

you can take @ page reference: https://msdn.microsoft.com/en-us/library/ee707357(v=vs.91).aspx


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -