Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why is this not working - please check my code - Role, Profile

Reply
Thread Tools

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

 
 
Annie
Guest
Posts: n/a
 
      03-05-2007
Hello guys,



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

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

Response.Write(rls(ctr))

Next

Even I do:

If User.IsInRole("Admin") Then

Response.Write("Yes")

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">

<connectionStrings>

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

providerName="System.Data.SqlClient" />

</connectionStrings>

<appSettings/>



<system.web>



<authentication mode="Forms">

<forms loginUrl="LOGIN.aspx">

</forms>

</authentication>



<!--

Don't allow the annonymous users and not logged ins

-->

<authorization>

<deny users="?" />

</authorization>



<!--

used by membership provider

-->



<membership defaultProvider="CustomizedProvider">

<providers>

<add name="CustomizedProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="NorthwindConnectionString"

applicationName="MembershipAndRoleCustomised"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" />

</providers>

</membership>



<!--

used by role provider

-->



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

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlRoleProvider"

applicationName ="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

</roleManager>



<!--

used by Profile

-->



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

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlProfileProvider"

applicationName="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>



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

<properties>

<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"/>

</group>

</properties>

</profile>



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

<pages>

<namespaces>

<clear/>

<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"/>

</namespaces>

</pages>



</system.web>

</configuration>




 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      03-05-2007
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
Roles.IsUserInRole(Page.User.Identity.Name,"Admin" )


--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Annie" <> wrote in message
news:...
> Hello guys,
>
>
>
> I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as
> below.
>
> 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
>
> Response.Write(rls(ctr))
>
> Next
>
> Even I do:
>
> If User.IsInRole("Admin") Then
>
> Response.Write("Yes")
>
> 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">
>
> <connectionStrings>
>
> <add name="NorthwindConnectionString" connectionString="Data
> Source=MYPC;Initial Catalog=Northwind;User ID=SA"
>
> providerName="System.Data.SqlClient" />
>
> </connectionStrings>
>
> <appSettings/>
>
>
>
> <system.web>
>
>
>
> <authentication mode="Forms">
>
> <forms loginUrl="LOGIN.aspx">
>
> </forms>
>
> </authentication>
>
>
>
> <!--
>
> Don't allow the annonymous users and not logged ins
>
> -->
>
> <authorization>
>
> <deny users="?" />
>
> </authorization>
>
>
>
> <!--
>
> used by membership provider
>
> -->
>
>
>
> <membership defaultProvider="CustomizedProvider">
>
> <providers>
>
> <add name="CustomizedProvider"
>
> type="System.Web.Security.SqlMembershipProvider"
>
> connectionStringName="NorthwindConnectionString"
>
> applicationName="MembershipAndRoleCustomised"
>
> minRequiredPasswordLength="5"
>
> minRequiredNonalphanumericCharacters="0" />
>
> </providers>
>
> </membership>
>
>
>
> <!--
>
> used by role provider
>
> -->
>
>
>
> <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
>
> <providers>
>
> <add name="CustomizedRoleProvider"
>
> type="System.Web.Security.SqlRoleProvider"
>
> applicationName ="MembershipAndRoleCustomised"
>
> connectionStringName="NorthwindConnectionString" />
>
> </providers>
>
> </roleManager>
>
>
>
> <!--
>
> used by Profile
>
> -->
>
>
>
> <profile defaultProvider="CustomProfileProvider" enabled="true">
>
> <providers>
>
> <add name="CustomizedRoleProvider"
>
> type="System.Web.Security.SqlProfileProvider"
>
> applicationName="MembershipAndRoleCustomised"
>
> connectionStringName="NorthwindConnectionString" />
>
> </providers>
>
>
>
> <!-- Define the properties for Profile... -->
>
> <properties>
>
> <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"/>
>
> </group>
>
> </properties>
>
> </profile>
>
>
>
> <compilation debug="true" strict="false" explicit="true"/>
>
> <pages>
>
> <namespaces>
>
> <clear/>
>
> <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"/>
>
> </namespaces>
>
> </pages>
>
>
>
> </system.web>
>
> </configuration>
>
>
>
>



 
Reply With Quote
 
 
 
 
Annie
Guest
Posts: n/a
 
      03-06-2007
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

Response.Write(rls(ctr))

Next

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



"Mark Fitzpatrick" <> wrote in message
news:%...
> 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
> Roles.IsUserInRole(Page.User.Identity.Name,"Admin" )
>
>
> --
>
> Hope this helps,
> Mark Fitzpatrick
> Former Microsoft FrontPage MVP 199?-2006
>
> "Annie" <> wrote in message
> news:...
>> Hello guys,
>>
>>
>>
>> I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as
>> below.
>>
>> 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
>>
>> Response.Write(rls(ctr))
>>
>> Next
>>
>> Even I do:
>>
>> If User.IsInRole("Admin") Then
>>
>> Response.Write("Yes")
>>
>> 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">
>>
>> <connectionStrings>
>>
>> <add name="NorthwindConnectionString" connectionString="Data
>> Source=MYPC;Initial Catalog=Northwind;User ID=SA"
>>
>> providerName="System.Data.SqlClient" />
>>
>> </connectionStrings>
>>
>> <appSettings/>
>>
>>
>>
>> <system.web>
>>
>>
>>
>> <authentication mode="Forms">
>>
>> <forms loginUrl="LOGIN.aspx">
>>
>> </forms>
>>
>> </authentication>
>>
>>
>>
>> <!--
>>
>> Don't allow the annonymous users and not logged ins
>>
>> -->
>>
>> <authorization>
>>
>> <deny users="?" />
>>
>> </authorization>
>>
>>
>>
>> <!--
>>
>> used by membership provider
>>
>> -->
>>
>>
>>
>> <membership defaultProvider="CustomizedProvider">
>>
>> <providers>
>>
>> <add name="CustomizedProvider"
>>
>> type="System.Web.Security.SqlMembershipProvider"
>>
>> connectionStringName="NorthwindConnectionString"
>>
>> applicationName="MembershipAndRoleCustomised"
>>
>> minRequiredPasswordLength="5"
>>
>> minRequiredNonalphanumericCharacters="0" />
>>
>> </providers>
>>
>> </membership>
>>
>>
>>
>> <!--
>>
>> used by role provider
>>
>> -->
>>
>>
>>
>> <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
>>
>> <providers>
>>
>> <add name="CustomizedRoleProvider"
>>
>> type="System.Web.Security.SqlRoleProvider"
>>
>> applicationName ="MembershipAndRoleCustomised"
>>
>> connectionStringName="NorthwindConnectionString" />
>>
>> </providers>
>>
>> </roleManager>
>>
>>
>>
>> <!--
>>
>> used by Profile
>>
>> -->
>>
>>
>>
>> <profile defaultProvider="CustomProfileProvider" enabled="true">
>>
>> <providers>
>>
>> <add name="CustomizedRoleProvider"
>>
>> type="System.Web.Security.SqlProfileProvider"
>>
>> applicationName="MembershipAndRoleCustomised"
>>
>> connectionStringName="NorthwindConnectionString" />
>>
>> </providers>
>>
>>
>>
>> <!-- Define the properties for Profile... -->
>>
>> <properties>
>>
>> <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"/>
>>
>> </group>
>>
>> </properties>
>>
>> </profile>
>>
>>
>>
>> <compilation debug="true" strict="false" explicit="true"/>
>>
>> <pages>
>>
>> <namespaces>
>>
>> <clear/>
>>
>> <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"/>
>>
>> </namespaces>
>>
>> </pages>
>>
>>
>>
>> </system.web>
>>
>> </configuration>
>>
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Want to profile monitor for Fuji Frontier ICC profile? Lynn Digital Photography 9 09-08-2005 12:17 PM
Java Web Start app icons keep going in user profile not All Users profile Brad Java 1 07-19-2005 02:10 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57