Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

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
0
allanmark
Asked:
allanmark
  • 4
  • 3
2 Solutions
 
TSmoothCommented:
By default, the SQLMembershipProvider uses a connection string called "LocalSQLServer" I believe. You need to either change the name of your connection string to that or you need to add a membership section to your web.config and specify that you want it to use the "SQLEXPRESS" connection string.
0
 
allanmarkAuthor Commented:
Just tried that. Same result.

ME = hopelessly confused!!!
0
 
allanmarkAuthor Commented:
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>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
allanmarkAuthor Commented:
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?
0
 
McExpCommented:
Does your configuration tag have an xmlns as below?
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

if so remove it and re-check?

This should stop the errors from occuring
0
 
McExpCommented:
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
0
 
allanmarkAuthor Commented:
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) ??
0
 
McExpCommented:
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now