Link to home
Create AccountLog in
Avatar of allanmark
allanmark

asked on

Problem configuring ASP.Net for Membership/Role functionality

Greetings,

I am in the process of using (or trying to) use Membership/roles in my application.

(1)  I added the following to my Web.Config:
<connectionStrings>
    <clear/>
    <add name="SQLEXPRESS"
         connectionString="Server=MASK\SQLEXPRESS;Database=SchoolKeeper;Trusted_Connection=Yes;"/>
  </connectionStrings>

(2)    Set Authentication mode to Forms:
  <authentication mode="Forms" />

(3) I ran ASPNET_REGSQL and verified that the asp tables were added to my database.

(4)  I then go into the ASP.Net App Configuration and added the following application setting:
  SQLEXPRESS = "Server=MASK\SQLEXPRESS;Database=SchoolKeeper;Trusted_Connection=Yes"

(5)  I then go to Security (or try to!) to add a User. The following happens:

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty. (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 140)

(6) I then opted to go re-select the ASPNetSqlProvider and tested it, to end up with the following:
Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.

(7) I went back to my Web.config file and saw that the following had been added:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings>
        <add key="SQLEXPRESS" value="Server=MASK\SQLEXPRESS;Database=SchoolKeeper;Trusted_Connection=Yes" />
    </appSettings>

This was along with 15 Messages:-
Message      1      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:configuration'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      10      2      D:\...\School_Keeper_ASP\
Message      2      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:appSettings'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      11      6      D:\...\School_Keeper_ASP\
Message      3      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:add'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      12      10      D:\...\School_Keeper_ASP\
Message      4      Could not find schema information for the attribute 'key'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      12      14      D:\...\School_Keeper_ASP\

ME = CONFUSED !!!!

WHAT SHOULD I BE DOING
ASKER CERTIFIED SOLUTION
Avatar of TSmooth
TSmooth

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of allanmark
allanmark

ASKER

Just tried that. Same result.

ME = hopelessly confused!!!
jUST HAD A PEEK IN THE mACHINE.coNFIG FILE AND SAW THIS:

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

I hadn't done it correctly. Now working!!!! THANKYOU !!!!!!!!!!!

If we could go back to my point no7:

(7) I went back to my Web.config file and saw that the following had been added:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings>
        <add key="SQLEXPRESS" value="Server=MASK\SQLEXPRESS;Database=SchoolKeeper;Trusted_Connection=Yes" />
    </appSettings>

This was along with 15 Messages:-
Message      1      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:configuration'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      10      2      D:\...\School_Keeper_ASP\
Message      2      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:appSettings'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      11      6      D:\...\School_Keeper_ASP\
Message      3      Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:add'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      12      10      D:\...\School_Keeper_ASP\
Message      4      Could not find schema information for the attribute 'key'.      D:\MyStuff - Allan\Training\School_Keeper_ASP\Web.config      12      14      D:\...\School_Keeper_ASP\

WHAT IS THIS? WHY AM I GETTING THESE ERRORS?
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Ok so I've just read your question again and it does look like you have the xmlns specified.

If you replace the line
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
with
<configuration>
you should be sorted
Took it out - solves problem - until I go into the ASP.NET Configuaration again. When I come out it asks me if I want to update the config, because blah ... blah. If I say, that line is back. Does this me that every time I go into the config and make changes,  I will have to delete the line (not a train smash if I must) ??
I assume you mean the ASP.NET web administration tool? There is a bug in the code this can be fixed but needs to be done on each devlopment machine used to configure the site.

Find the file:
%windir%\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs
Update the Line:
config.NamespaceDeclared = true;
to
config.NamespaceDeclared = false;

On future invocations of the tool it should not reappend the Namespace Decleration.