Your SlideShare is downloading. ×
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Implement custom iprincipal in mvc
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Implement custom iprincipal in mvc

762

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
762
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. How to implement a custom IPrincipal in ASP.NET MVC Nat 20140224
  • 2. Why ?  We want more user information in Principal object  Ex.  User.MemberID  User.LoginID
  • 3. IPrincipal and IIdentity  System.Security.Principal.IPrincipal    Page.User Controller.User System.Security.Principal.IIdentity  User.Identity
  • 4. How  Define a class which implements IPrinicpal interface    Save custom settings to Cookie Restore custom settings on every request Replace User object on PostAuthenticateRequest event
  • 5. Implementation  public class CustomPrincipalSerializeModel  public class CustomPrincipal : IPrincipal  Signin – save custom settings   Login action Request – restore custom settings  Global.asax - Application_PostAuthenticateRequest
  • 6. Implementation  Replace (User as CustomPrincipal).LoginID with User.LoginID  public class CustomController : Controller
  • 7. Implementation  Replace @(User as CustomPrincipal).MemberID With @(User.MemberID)  public abstract class CustomWebViewPage : WebViewPage  public abstract class CustomWebViewPage<TModel> : WebViewPage<TModel>  Views/Web.config  <pages pageBaseType="CustomWebViewPage">
  • 8. Reference  http://www.codeproject.com/Tips/574576/How-to-implement-a-customIPrincipal-in-ASP-NET-MV  http://stackoverflow.com/questions/1064271/asp-net-mvc-set-customiidentity-or-iprincipal

×