Ask a Question related to ASP.NET Security, Design and Development.
-
rh #1
Best way to handle AuthenticateRequest?
I've been reading a lot of articles about how to handle roles based security in ASP.NET and I've seen two popular methods of handling AuthenticateRequest and I'm curious which is preferred. (I've omitted most error checking to simplify the code).
Option 1 (from MSDN patterns & practices - extract cookie and decrypt):
---
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (authCookie == null)
return;
FormsAuthenticationTicket authTicket = null;
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
string[] roles = authTicket.UserData.Split(new char[]{'|'});
FormsIdentity id = new FormsIdentity( authTicket );
GenericPrincipal principal = new GenericPrincipal(id, roles);
Context.User = principal;
---
Option 2 (various articles - cast identity, get forms ticket):
---
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
string userData = ticket.UserData;
string[] roles = userData.Split(',');
HttpContext.Current.User = new GenericPrincipal(id, roles);
---
Option 2 makes me think the FormsAuthentication class is doing a lot of stuff behind the scenes but I haven't found the documentation on it (not that it doesn't exist). Is the FormsAuthentication class automatically picking up the cookie and decrypting it with each page request? And if this is the case, then why does the "official" MS method ignore this feature and do things manually?? Thanks for the input!
rh Guest
-
Tie::Handle::CSV Help...
Hello All,, I need some assistance please, i've been fussing with this for a while but i'm stuck. What i need here is, while my Style column... -
Can I Handle Error 404 JUST Using ASP ?
understand that through IIS you can implement custom error messages, but since we are in hosted environment, we need to implement custom error... -
handle the IE.
Hello, I need to show full screen, when IE is shown. Can I handle the appearence of IE by some flash commands ? Also, can I hanlde the html,... -
I cannot handle Tables!
I get very surprized when I set everything accurately and corrently in Dremweaver and I get a bad result in the browser! How is this possible to set... -
handle file > 2GB
Hi there, Anyone know how to handle file size > 2GB in SUN? I called stat but it fail with EOVERFLOW if the file > 2GB. TIA



Reply With Quote

