Groups | Blog | Home
all groups > asp.net security > september 2007 >

asp.net security : RoleProvider Roles cookieName reading/setting


Chuck P
9/19/2007 9:18:01 AM
Is their a way to read the name and preferably set the name of the
RoleProvider Roles.CookieName.

I have a class

public sealed class MyRoleProvider : RoleProvider
{
public override void Initialize(string providerName,
NameValueCollection providerWebConfig)
{
//this works
this.ApplicationName = "Yada Yada";

//this crashes
wawang NO[at]SPAM online.microsoft.com (
9/20/2007 12:00:00 AM
Hi Chuck,

I think accessing Roles.CookieName at this moment might cause recursive
calling since the RoleProvider haven't get fully initialized yet.

If your objective here is to read the CookieName, you might use following
workaround:

Configuration cfg =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
System.Web.Configuration.RoleManagerSection rm =
(System.Web.Configuration.RoleManagerSection)cfg.GetSection("system.web/role
Manager");
string cookieName = rm.CookieName;


Could you please tell me why you need to change it in your RoleProvider's
initialize method?


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Chuck P
9/20/2007 6:50:00 AM
In our roleprovider class we want to ensure the cookiename is set to the same
value as a value set in appSettings; The applications name. I don't have to
wawang NO[at]SPAM online.microsoft.com (
9/21/2007 12:00:00 AM
Hi Chuck,

Unfortunately the Roles.CookieName is a read-only property, and it cannot
be overridden. It's always returning the property from <roleManager>
element in web.config.

Please submit your feature request here:

http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220

This site is monitored by our product group directly. Thanks for your
feedback.



Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button