Wrox Programmer Forums
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 9th, 2010, 04:50 AM
Registered User
Join Date: Apr 2010
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Wrox Blog - ASPNET Roles not working

Hi There,

I am having a problem with the WROX blog app from Chapter 6. I am using Visual Studio 2008 with SP1, and SQL 2005 Express on my dev PC. I am trying to publish to a Win 2003 Server, using SQL Server 2005, and IIS 6.0

I have created the Administrator role in the Blog (ASPNET) DB and added a user to it. When Running locally I can log in and create new blog entries.

On the Server, I have attached the database in SQL 2005 manager and granted the IWAM account Execute privileges for all sp's and ownership of the blog db.

I can login (& out) using the new account I created, but the option to create new entries does not appear.

I then repeated the entire process using a C# version of the Blog that someone had ported from VB (I'm trying to learn C#), with exactly the same problem.

I put some debug code into the c# version, Default.aspx.cs to write the assigned Role to a label on the blog page:

protected void Page_Load(object sender, EventArgs e)
        string[] userRoles = ((RolePrincipal)Context.User).GetRoles();
            lblRoles.Text = userRoles[0];
            lblRoles.Text = "No Roles Defined";

Which when run locally under VS2008, after logging in the label showed "Administrator", and I am able to create new entries.

However, when running on the server, although I log in, the label shows that "No Roles Defined" and I am unable to create new entries.

Any help would be greatly appreciated.

Web.config below:

<?xml version="1.0"?>
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <add key="DefaultConnectionString" value="SqlServerConnectionString" />
    <add key="EmailFrom" value="You@YourProvider.Com"/>
    <add key="EmailTo" value="You@YourProvider.Com"/>
    <add key="FCKeditor:UserFilesPath" value="/Blog/UserFiles"/>

<add name="SqlServerConnectionString" connectionString="Data Source=(local);Initial Catalog=blog;Integrated Security=True"
   providerName="System.Data.SqlClient" />


            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
    <trace enabled="true" />
    <compilation debug="true" strict="false" explicit="true" />

        <clear />
        <add name="AspNetSqlMembershipProvider"
            type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

    <roleManager enabled="true"
        <add connectionStringName="SqlServerConnectionString" name="SqlProvider"
          type="System.Web.Security.SqlRoleProvider" />

            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" path="/" protection="All" />

            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
    <customErrors mode="Off" defaultRedirect="ErrorPage.aspx">
      <error statusCode="404" redirect="ErrorPage.aspx"/>
      <error statusCode="500" redirect="ErrorPage.aspx"/>

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

      <smtp deliveryMethod="Network">
        <network host="smtp.YourProvider.com" port="25" />

Old April 9th, 2010, 12:30 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

The problem is probably caused by a mismatch in the application name between membership and roles.

Try setting the applicationName attribute for the <roleManager /> elemement to "/" as well on your local database. Then recreate and assign the users and try again.

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
hughest7 (April 9th, 2010)
Old April 9th, 2010, 06:55 PM
Registered User
Join Date: Apr 2010
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts

Many thanks for your help Imar. That sorted the problem.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox Blog in C# madAlan BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 22 June 12th, 2011 04:09 AM
Wrox Blog Problem ddormody BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 September 27th, 2008 09:38 AM
Wrox Blog tblessed23 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 16 May 14th, 2007 04:08 PM
Wrox Blog: Viewing individual blog entries Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 7th, 2007 12:06 PM
Wrox blog suggestions nakori BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 June 15th, 2006 04:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.