RoleProvider Roles cookieName reading/setting

C

Chuck P

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
if (!string.IsNullOrEmpty( Roles.CookieName))
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 
C

Chuck P

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
change it in intialize, but I would like to set it somewhere.
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top