| | |
ASP.NET 2.0 equivalent Please
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Hi there ladies and gentlemen!
I have this code that works in ASP.NET 1.1 but I could not find its equivalent in v 2.0. I had expected it to work having the usual backward compatibility preached by microsoft in mind. But I am yet to succeed. The code 'translation' worked until the need to program in the global.asax file.
The problem is about role based authentication of users using 'forms' authentication. In v1.1 the portion where the need arises to construct GenericPrincipal and formsIdentity objects works well but I cannot find the reference to the GenericPrincipal objects in v2.0
This is version 1.1 code snippets
In the Application_AuthenticateRequest event handler I add the following code
Version 2.0
All is well until you get to
OR
Maybe the question should be where or how do we include the following the in global.asax file in v2.0
Pls any help would be appreciated!
I have this code that works in ASP.NET 1.1 but I could not find its equivalent in v 2.0. I had expected it to work having the usual backward compatibility preached by microsoft in mind. But I am yet to succeed. The code 'translation' worked until the need to program in the global.asax file.
The problem is about role based authentication of users using 'forms' authentication. In v1.1 the portion where the need arises to construct GenericPrincipal and formsIdentity objects works well but I cannot find the reference to the GenericPrincipal objects in v2.0
This is version 1.1 code snippets
ASP.NET Syntax (Toggle Plain Text)
//included at the top of the global.asax file using System.Web.Security; using System.Security.Principal;
In the Application_AuthenticateRequest event handler I add the following code
ASP.NET Syntax (Toggle Plain Text)
// Extract the forms authentication cookie string cookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = Context.Request.Cookies[cookieName]; if(null == authCookie) { // There is no authentication cookie. return; } FormsAuthenticationTicket authTicket = null; try { authTicket = FormsAuthentication.Decrypt(authCookie.Value); } catch(Exception ex) { return; } if (null == authTicket) { // Cookie failed to decrypt. return; } // When the ticket was created, the UserData property was assigned a // pipe delimited string of role names. string[] roles = authTicket.UserData.Split(new char[]{'|'}); // Create an Identity object FormsIdentity id = new FormsIdentity( authTicket ); // This principal will flow throughout the request. GenericPrincipal principal = new GenericPrincipal(id, roles); // Attach the new principal object to the current HttpContext object Context.User = principal;
Version 2.0
All is well until you get to
ASP.NET Syntax (Toggle Plain Text)
//you cannot include at the top of the global.asax file using System.Web.Security; using System.Security.Principal; // This principal will flow throughout the request - you cannot find the genericprincipal object!. GenericPrincipal principal = new GenericPrincipal(id, roles); // Attach the new principal object to the current HttpContext object Context.User = principal;
OR
Maybe the question should be where or how do we include the following the in global.asax file in v2.0
ASP.NET Syntax (Toggle Plain Text)
//you cannot include at the top of the global.asax file using System.Web.Security; using System.Security.Principal;
Pls any help would be appreciated!
Last edited by jamello; Feb 11th, 2008 at 3:28 pm.
•
•
•
•
Looks like you have it right... System.Security.Principal.GenericPrincipal
What error are you getting?
The point is that I cannot find or create the generic principal objects mainly because I cannot reference the objects by the usage of the "using" clause at the top of the global.asax file. So I repeat, How do I include this code or how do I make the generic principal objects available for use in the global.asax file.I do hope I am clearer.
Thanks
•
•
•
•
Looks like you have it right... System.Security.Principal.GenericPrincipal
What error are you getting?
The point is that I cannot find or create the generic principal objects mainly because I cannot reference the objects by the usage of the "using" clause at the top of the global.asax file. So I repeat, How do I include this code or how do I make the generic principal objects available for use in the global.asax file.I do hope I am clearer.
Thanks
•
•
Join Date: Feb 2008
Posts: 62
Reputation:
Solved Threads: 4
Sorry, I misunderstood. You can always fully qualify the names (use System.Security.Principal.GenericPrincipal anywhere that you are currently using GenericPrincipal). Otherwise, this article explains why you can't use the "using" key and offers a workaround: http://rossnelson.blogspot.com/2005/...aspnet-20.html
I hope this helps!
I hope this helps!
•
•
•
•
Sorry, I misunderstood. You can always fully qualify the names (use System.Security.Principal.GenericPrincipal anywhere that you are currently using GenericPrincipal). Otherwise, this article explains why you can't use the "using" key and offers a workaround: http://rossnelson.blogspot.com/2005/...aspnet-20.html
I hope this helps!
And the blogpost you suggested? SUPER DUPER!!!!
Gracias A Plenty!!!!!!
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- What is the equivalent code of MessageBox in ASP.Net? (ASP.NET)
- How Can I Download Templates For ASP.Net? (ASP.NET)
- Equivalent ASP Snippet for PHP Spam Trap (ASP)
- ASP in ASP.NET application (ASP.NET)
- C#ASP.Net: how to browse the folder list on Server? (C#)
Other Threads in the ASP.NET Forum
- Previous Thread: What is the equivalent code of MessageBox in ASP.Net?
- Next Thread: Removing Query Strings
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox child class compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form gridview gudi iis image javascript list listbox menu mouse mssql nameisnotdeclared news novell numerical opera order parent problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security select serializesmo.table sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview typeof validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming wizard xsl





