I am trying to implement an example of the built in login and createuser wizard. the ony problem is, (and this may be really retarded of me) is that when i publish it out to a web server it doesn't work. Of course, it works perfect locally.

Does the aspnetdb.mdf that runs on my computer not run on the real server?

Ideally, I want this to run off a remote SQL database, but I am not sure how to set that up... I see in the help and online that I am aupposed to be able to slect another source to store this data on the "Provider" tab, but I don't see that optoin.

When I click the ASP.NET Configuration Tool all i can see on the page for my optoins are:
--------------------------------
Use this page to select a provider for each feature.

Membership Provider
AspNetSqlMembershipProvider -CHECKED


Role Provider
AspNetSqlRoleProvider -CHECKED
AspNetWindowsTokenRoleProvider

-------------------------------------
So, I'd like to know the answer to 2 questions:
1-Can the aspnetdb.mdf that runs on my computer run on the real server?
2-how can I convert this to use a remote SQL database, ie, I can't see where to set the datasource as I do in the drigeview, detailsview etc portions of the visual web devloper express program...

Thanks For Your Help!

Andrea

Dani AI

Generated

Short answer: the local aspnetdb.mdf used by Visual Web Developer is a SQL Server Express user-instance file and will not be magically used by a remote IIS/SQL Server host. Two practical routes exist: attach the MDF on the host (host-dependent and often not allowed on shared hosting), or create a normal database on the remote server, install the ASP.NET membership schema there, and point the membership/role providers to that remote connection string.

Recommended minimal workflow (high level):

  1. Obtain the remote SQL Server name, credentials and create an empty database (via host control panel or SQL Server Management Studio).
  2. Install the membership schema into that database. From a framework command prompt run the ASP.NET registration tool, for example:
aspnet_regsql.exe -S serverName\instance -U dbUser -P dbPassword -d DatabaseName -A all
  1. Update web.config so a connectionStrings entry points to the remote DB and set the membership/role providers’ connectionStringName to that entry (keep the same applicationName across environments). As @f1fan outlined, this is the correct approach; editing web.config directly is the most reliable method if the ASP.NET Configuration Tool (WSAT) or the Provider tab isn’t available in the Express edition.

Troubleshooting and gotchas: the error seen by ("start tag ... does not match the end tag") is an XML nesting problem — check for missing/extra closing tags and ensure only one <system.web> block contains <authentication>, <membership> and <roleManager>. A minimal structure looks like:

<configuration>
  <connectionStrings>...</connectionStrings>

  <system.web>
    <authentication>...</authentication>
    <membership>...</membership>
    <roleManager>...</roleManager>
  </system.web>
</configuration>

Other checks: verify the aspnet_* tables exist after running aspnet_regsql, test the DB login from the server (firewall/TCP-IP/instance name can block remote connections), and beware that many shared hosts do not permit AttachDbFilename/user instances — in that case run the schema on their SQL Server or ask host support. For production, consider encrypting the connectionStrings section (aspnet_regiis) so credentials aren’t stored in clear text.

Recommended Answers

All 4 Replies

I think there's a way to attach the mdf file to Sql Server on the remote host during deployment or in the application config or something. I've never done it cos we run our own web-servers and db-servers. But I'll see what I can find out.

To use a remote SQL Server you need to add the settings to your web config. At the top you need to add the connection string

<connectionStrings>
		<add name="MyConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=[I]servername[/I];Initial Catalog=[I]database[/I];UID=[I]username[/I];pwd=[I]password[/I]"/>
	</connectionStrings>

Then you need to change authentication mode to forms and add the providers.

<authentication mode="Forms">
			<forms name="[I]appname[/I]" loginUrl="login.aspx" protection="All" path="/" timeout="60"/>
		</authentication>
		<membership defaultProvider="MySqlLoginProvider">
			<providers>
				<add name="MySqlLoginProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString" applicationName="[I]appname[/I]" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" passwordAttemptWindow="30" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/>
			</providers>
		</membership>
		<roleManager defaultProvider="MyRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPRoles" cookiePath="/" cookieTimeout="60" cookieSlidingExpiration="true" cookieProtection="All">
			<providers>
				<add name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyConnectionString" applicationName="[I]appname[/I]"/>
			</providers>
		</roleManager>

Now when you go to the admin site you will see the new providers and test them :)

To use a remote SQL Server you need to add the settings to your web config. At the top you need to add the connection string

<connectionStrings>
		<add name="MyConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=[I]servername[/I];Initial Catalog=[I]database[/I];UID=[I]username[/I];pwd=[I]password[/I]"/>
	</connectionStrings>

Then you need to change authentication mode to forms and add the providers.

<authentication mode="Forms">
			<forms name="[I]appname[/I]" loginUrl="login.aspx" protection="All" path="/" timeout="60"/>
		</authentication>
		<membership defaultProvider="MySqlLoginProvider">
			<providers>
				<add name="MySqlLoginProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnectionString" applicationName="[I]appname[/I]" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" passwordAttemptWindow="30" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/>
			</providers>
		</membership>
		<roleManager defaultProvider="MyRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPRoles" cookiePath="/" cookieTimeout="60" cookieSlidingExpiration="true" cookieProtection="All">
			<providers>
				<add name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyConnectionString" applicationName="[I]appname[/I]"/>
			</providers>
		</roleManager>

Now when you go to the admin site you will see the new providers and test them :)

I tried this but its still not working for me, I get the following errors , can anyone assist.

System.Configuration.ConfigurationErrorsException: The 'system.web' start tag on line 16 does not match the end tag of 'authentication'. Line 57, position 9. (C:\WebSite1\web.config line 57) ---> System.Xml.XmlException: The 'system.web' start tag on line 16 does not match the end tag of 'authentication'. Line 57, position 9. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Configuration.XmlUtil.CopySection() at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(XmlUtil xmlUtil, String parentConfigKey, Boolean inLocation, String locationSubPath, OverrideModeSetting overrideMode, Boolean skipInChildApps) at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(XmlUtil xmlUtil, String parentConfigKey, Boolean inLocation, String locationSubPath, OverrideModeSetting overrideMode, Boolean skipInChildApps) at System.Configuration.BaseConfigurationRecord.ScanSections(XmlUtil xmlUtil) at System.Configuration.BaseConfigurationRecord.InitConfigFromFile() --- End of inner exception stack trace --- at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal) at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors) at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams) at System.Configuration.Internal.InternalConfigConfigurationFactory.System.Configuration.Internal.IInternalConfigConfigurationFactory.Create(Type typeConfigHost, Object[] hostInitConfigurationParams) at System.Web.Configuration.WebConfigurationHost.OpenConfiguration(WebLevel webLevel, ConfigurationFileMap fileMap, VirtualPath path, String site, String locationSubPath, String server, String userName, String password, IntPtr tokenHandle) at System.Web.Configuration.WebConfigurationManager.OpenWebConfigurationImpl(WebLevel webLevel, ConfigurationFileMap fileMap, String path, String site, String locationSubPath, String server, String userName, String password, IntPtr userToken) at System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, String path) at System.Web.Administration.WebAdminPage.OpenWebConfiguration(String path, String appPhysPath, Boolean getWebConfigForSubDir) at System.Web.Administration.WebAdminPage.OpenWebConfiguration(String path, Boolean getWebConfigForSubDir) at System.Web.Administration.WebAdminPage.VerifyAppValid()

I would like to create login page in asp.net for a project by using web site adminstration tool. Please send any procedure to do it and if any code is for this please send this
Thanking you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.