Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 363963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:23:34+00:00 2026-05-12T13:23:34+00:00

I have an ASP.NET v2.0 website (not web application) where the root directory is

  • 0

I have an ASP.NET v2.0 website (not web application) where the root directory is public, but the “Admin” subdirectory requires authentication. Everything about the setup is very generic – I used a connection string defined in the root web.config, and the standard AspNetSqlMembershipProvider provider, and I’m using the ASP.NET Login control.
The web.config in the Admin directory specifies that the user must have the “Admin” role.

I’m using SQL Server 2008, and my connection string is good; every root level page is data driven and they all work fine.
Provider configuration seems goo.

when I log in, the Login control’s “OnLoggedIn” event fires.
The last line in that event code redirects me down to my Admin/Default.aspx page. My breakpoint in “OnLoggedIn” shows me that all’s well until the redirect down into my Admin directory…and then…

…and then I wait…and wait…

And then I get an error telling me it’s experienced a “SQLExpress database file auto-creation error.”

Why in the world is it suddenly trying to create a SQL Server Express file? Why is it suddenly ignoring my connection string?

One odd clue: Just before the last line of the “OnLoggedIn” event I put in this:

bool blnTest = User.IsInRole("Admin");

I wanted to see if blnTest = true.
What happens is the process hits this line…and waits…and eventually tells me it can’t access the SQL Server Express database. It seems that any reference (either in my code, or behind the scenes) to determine the User’s Role, calls the wrong database.

EDIT: Argh, sometimes it waits when I test blnTest. Other times it immediately reports the value as “false.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:23:34+00:00Added an answer on May 12, 2026 at 1:23 pm

    According to your comment, it looks like you have haven’t explicitly configured a role provider for you site.

    If all that’s in your web.config is:

    <roleManager enabled="true" />
    

    Then you are relying on the default providers declared further up the configuration hieracrchy (machine.config, global web.config, etc)

    In machine.config you’ve probably got something like:

    <roleManager>
      <providers>
        <add name="AspNetSqlRoleProvider" 
          connectionStringName="LocalSqlServer" 
          applicationName="/" 
          type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        <add name="AspNetWindowsTokenRoleProvider" 
          applicationName="/" 
          type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </providers>
    </roleManager>
    

    As you can see, the first provider is configured to use a connectionString called LocalSqlServer – which is also usually declared in the machine.config:

    <add name="LocalSqlServer" 
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
         providerName="System.Data.SqlClient"/>
    

    And this is designed to use a local file based database that will be created if it doesn’t already exist.

    So to get roles working on your site, you should ammend your root web.config to something like:

    <roleManager enabled="true">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" 
          connectionStringName="YourConnectionStringName" 
          applicationName="/" 
          type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </providers>
    </roleManager>
    

    Using the <clear /> element will remove all previously defined providers for that type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net website that uses forms authentication. There are a few things
I currently have an asp.net website hosted on two web servers that sit behind
I have a .NET v4 application consisting of a web application (ASP.NET MVC2) and
I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net
I have an ASP.NET website and when I press F5 it automatically attaches to
I have an ASP.net website ( http://www.erate.co.za ) version 2.0. When someone opens my
I have an asp.net website that allows the user to download largish files -
I have an ASP.NET website (in C#) that takes in user data and then
We have a large ASP.Net website that has a single css stylesheet which is
I have an ASP.Net hosted website which displays a list of results as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.