By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,585 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

2.0 Forms Authentication Prob.

P: n/a
I'm trying to use 2.0 forms authentication in a new web site. My book shows
how to set this up with the ASP.Net Web Site Administration Tool by going to
the Security tab and following the instructions there.

However, on this page I get an "Unable to connect to SQL Server database"
message. Checking further I'm told (by my book) that a SQL Server Express
database named AspNetDB.mdf is created automatically for me in my App_Data
folder - but it's not.

I'm not using SqlServer express as I am using SqlServer Developer edition.

So, how can I get the right database created to use 2.0 forms
authentication?

(Actually I would want the files in my application database if that's
possible).

Thanks,

G


Jun 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This article goes into some of the details:
http://www.eggheadcafe.com/articles/20060529.asp
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"GaryDean" wrote:
I'm trying to use 2.0 forms authentication in a new web site. My book shows
how to set this up with the ASP.Net Web Site Administration Tool by going to
the Security tab and following the instructions there.

However, on this page I get an "Unable to connect to SQL Server database"
message. Checking further I'm told (by my book) that a SQL Server Express
database named AspNetDB.mdf is created automatically for me in my App_Data
folder - but it's not.

I'm not using SqlServer express as I am using SqlServer Developer edition.

So, how can I get the right database created to use 2.0 forms
authentication?

(Actually I would want the files in my application database if that's
possible).

Thanks,

G


Jun 12 '06 #2

P: n/a
Thanks for Peter's inputs,

Hi Gary,

Have you ever installed the SQL Server Express edition on that server
machine? If not, this is the expected behavior because by default,
ASP.NET's formsauthentication(membership/role provider) is configured to
use SqlServer provider , and the default connectionstring(used by this
provider) is pointing to a local SQL Express database file( in App_Data
folder), this is preconifguerd in machine.config(as below):

==============
<connectionStrings>
<add name="LocalSqlServer" connectionString="data
source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
...................
<system.web>
<processModel autoConfig="true" />
<httpHandlers />
<membership>
<providers>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
.................
=============================

Certainly we can override this in our ASP.NET web application's web.config
file. e.g

#membership Element (ASP.NET Settings Schema)
http://msdn2.microsoft.com/en-us/library/1b9hw62f.aspx

================
<system.web>
.......................
<membership>
<providers defaultProvider="MySqlMembershipProvider">

<add name="MySqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="NewSQLConnStr" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
==========================

The above configuration setting add a new configured provider(still use the
SqlMembershipProvider class), but change to use a new connectionstring
(named "NewSQLConnStr"). You can then add a new connectionstring which
point to a certain database in the SQL Server engine(2000 or 2005).
Also, we can use the aspnet_regsql.exe tool to setup and initialize the sql
provider specific tables/functions in a specfic database:

#ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe)
http://msdn2.microsoft.com/en-us/library/ms229862.aspx

In addition, here is another good web article which describes detailed on
configuring membership/role service in ASP.NET 2.0:

# Examining ASP.NET 2.0's Membership, Roles, and Profile - Part 1
http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

Hope this helps. If there is anything unclear in the above items, please
feel free to post here.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 12 '06 #3

P: n/a
Hey Gary,

Have you got any further ideas on this issue or does my last reply also
help you some? If you still need any further assistance, please don't
hesitate to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.