Why is this not working - please check my code - Role, Profile



Hello guys,

I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as

I just want to use my own sql server 2000 table instead of MSDB.

I have used the ASP.net Configruation Page to add couple of users

and roles and then assigned the users to roles.

The membership is working fine it connects to my database. However the
Rolemanager and the Profile is not working.

For roles I test like this:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1



Even I do:

If User.IsInRole("Admin") Then


End If

But it doesn't work.

For Profile when I type Profile and then (.), it shows all the other details
of the Profile object but not the customised properties I have added.

Any input will be much appreciated. Many thanks

Config file

<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">


<add name="NorthwindConnectionString" connectionString="Data
Source=MYPC;Initial Catalog=Northwind;User ID=SA"

providerName="System.Data.SqlClient" />




<authentication mode="Forms">

<forms loginUrl="LOGIN.aspx">




Don't allow the annonymous users and not logged ins



<deny users="?" />



used by membership provider


<membership defaultProvider="CustomizedProvider">


<add name="CustomizedProvider"





minRequiredNonalphanumericCharacters="0" />




used by role provider


<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">


<add name="CustomizedRoleProvider"


applicationName ="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />




used by Profile


<profile defaultProvider="CustomProfileProvider" enabled="true">


<add name="CustomizedRoleProvider"



connectionStringName="NorthwindConnectionString" />


<!-- Define the properties for Profile... -->


<add name="HomepageUrl" type="String" serializeAs="String"
allowAnonymous="true" />

<group name="Bio">

<add name="BirthDate" type="DateTime" serializeAs="Xml"
allowAnonymous="true" />

<add name="Location" type="String" allowAnonymous="true"/>




<compilation debug="true" strict="false" explicit="true"/>




<add namespace="System"/>

<add namespace="System.Collections"/>

<add namespace="System.Collections.Specialized"/>

<add namespace="System.Configuration"/>

<add namespace="System.Text"/>

<add namespace="System.Text.RegularExpressions"/>

<add namespace="System.Web"/>

<add namespace="System.Web.Caching"/>

<add namespace="System.Web.SessionState"/>

<add namespace="System.Web.Security"/>

<add namespace="System.Web.Profile"/>

<add namespace="System.Web.UI"/>

<add namespace="System.Web.UI.WebControls"/>

<add namespace="System.Web.UI.WebControls.WebParts"/>

<add namespace="System.Web.UI.HtmlControls"/>







Mark Fitzpatrick

Couple things, first the profiles. Are you using the Web Application
Project? That's the project that was added to VS as an independent add-in,
and then as part of SP 1. The Web Application Project is different from the
Web Site Project in that it compiles everything into a single dll at build.
The Web Site Project did things dynamically, which meant that the profile
classes were created on the fly when the site was visited. Unfortunately,
this doesn't work with the Web Application Project type. There's an add-in
though that can generate the classes for you so they can be compiled into
your app at: http://workspaces.gotdotnet.com/AspWebProfileGenerator

With luck, that will solve a lot of those issues.

Now, the roles. Keep in mind that User.IsInRole simply tests a cookie to see
if that role is there. Try instead the Roles.IsUserInRole("Admin") or




Dear Mark,

Yes you are right. I am using the web application project.
I will try to download the add in and install it and hope it will work.

In regarding to RoleManager I am trying to do it as:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1



Even this one doesn't work ... ie I am using the object model for the Roles.
Could it be affected by the web project too?

many thanks

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