• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1500
  • Last Modified:

Publish ASP.NET and ASPNETDB.mdf into production

Could someone please explain to me, step by step, how to publish an ASP.NET application with login security.  I created a user within the web administration tool in Visual Studio 2005, which created the ASPNETDB.mdf database.  

Although I can login successfully when I run the app in VS2005, when I deploy it to a production server it will not run.  My understanding is the ASPNETDB.mdf needs to be attached to my sql server.  I have attempted this but still not working.  

Can someone please take me through the "cradle to grave" steps for this process.  I have spent three days in forums with no luck.  
0
sinsoush
Asked:
sinsoush
  • 3
  • 3
1 Solution
 
hemaldesaiCommented:
Ok First thing i'll suggest is not to use two different DBs for your Authentication and one for your application. There is a commandline utility which is located ?%system%/WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe /w

this will launch a wizard, you have to provide it with the DB you want to upgrade to work as a ASPNETMembership and Role Provider. Once this steps are done your DB will be able to manage your Membership.

Next Step is to modify your web.config file to hand the membership via this new DB.

Step 1 : Create a Connection String which will be pointing to this new DB which is attached to a SQL server.
Step 2 : Update your <membership> Tag & Add Provider
Step 3 : Update your <Role> tag & Add Provider
Step 4 : Run ASP.net Administration console and change the provider to this new providers.
Step 5 : setup your user accounts and you are done.

For your production server.
Step 1 : Take the backup of this DB and restore it on the server.
Step 2 : update you connection string with respect to your new DB server
Step 3 : Deploy your site.

Regards
Hemal

Attached is the a sample of web.config parts you need to edit

	<connectionStrings>
		<add name="myConnectionString" connectionString="Data Source=MyServer;Initial Catalog=myDB;Persist Security Info=True;User ID=MyUser;Password=MyPassword" providerName="System.Data.SqlClient"/>
	</connectionStrings>
 
		<membership defaultProvider="MyMembershipProvider">
			<providers>
				<remove name="AspNetSqlMembershipProvider"/>
				<add connectionStringName="myConnectionString" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" name="MyMembershipProvider" applicationName="/" type="System.Web.Security.SqlMembershipProvider"/>
			</providers>
		</membership>
		<roleManager defaultProvider="MyRoleProvider" enabled="true">
			<providers>
				<remove name="AspNetSqlRoleProvider"/>
				<add type="System.Web.Security.SqlRoleProvider" name="MyRoleProvider" applicationName="/" connectionStringName="myConnectionString"/>
			</providers>
		</roleManager>

Open in new window

0
 
sinsoushAuthor Commented:
Thank you Hemal,
Please forgive me b/c I have going to take this slowly...your solutions sounds like you know what you are talking about and i want to do your steps correctly.

In the web.config file you included you have two section that state: applicationName="/"
If my test application is simply called WebSite5, should this change to applicationName="/WebSite5" ?

I tried making the web.config changes you recommend and when I build my application I get an error that says: Unrecognized configuration section membership

Please see the screen shot attached...thank you for working with me on this!

Travis
Unrecognized-configuration-secti.JPG
0
 
hemaldesaiCommented:
leave the applicationName="/"  as it is. This tells this is the root

Am attaching a web.config file of one of my projects check that out.


am out for dinner now but will check back for your questions in couple of hours.

hemal
<?xml version="1.0"?>
<configuration>
	<configSections>
		<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
			<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
				<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
					<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
					<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
					<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
				</sectionGroup>
			</sectionGroup>
		</sectionGroup>
		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections>
	<connectionStrings>
		<add name="c2vConnectionString" connectionString="Data Source=SUPERMAN\SQLEXPRESS;Initial Catalog=c2v;Persist Security Info=True;User ID=sa;Password=sf5500bb" providerName="System.Data.SqlClient"/>
	</connectionStrings>
	<system.web>
		<customErrors defaultRedirect="~/Error.aspx"/>
		<authorization>
			<allow roles="Administrators"/>
			<allow roles="Buyers"/>
			<allow roles="Vendors"/>
		</authorization>
		<authentication mode="Forms">
			<forms name="frmLogin" loginUrl="Login.aspx" defaultUrl="Default.aspx"/>
		</authentication>
		<membership defaultProvider="c2vMembership">
			<providers>
				<remove name="AspNetSqlMembershipProvider"/>
				<add connectionStringName="c2vConnectionString" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" name="c2vMembership" applicationName="/" type="System.Web.Security.SqlMembershipProvider"/>
			</providers>
		</membership>
		<roleManager defaultProvider="c2vRoleProvider" enabled="true">
			<providers>
				<remove name="AspNetSqlRoleProvider"/>
				<add type="System.Web.Security.SqlRoleProvider" name="c2vRoleProvider" applicationName="/" connectionStringName="c2vConnectionString"/>
			</providers>
		</roleManager>
		<pages>
			<controls>
				<!-- 		This tag is commented as a newer version of the Ajax Tools are beeing refered 
        <add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
				<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> -->
				<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>
			<tagMapping>
				<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
			</tagMapping>
		</pages>
		<!-- 
          Set compilation debug="true" to insert debugging 
          symbols into the compiled page. Because this 
          affects performance, set this value to true only 
          during development.
    -->
		<compilation debug="true">
			<assemblies>
				<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
				<add assembly="Microsoft.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
		</compilation>
		<httpModules>
			<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules>
		<httpHandlers>
			<remove verb="*" path="*.asmx"/>
			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers></system.web>
	<system.webServer>
		<handlers>
			<remove name="WebServiceHandlerFactory-Integrated"/>
			<remove name="ScriptHandlerFactory"/>
			<remove name="ScriptHandlerFactoryAppServices"/>
			<remove name="ScriptResource"/><remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers>
		<validation validateIntegratedModeConfiguration="false"/>
		<modules>
			<remove name="ScriptModule"/>
			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules></system.webServer>
	<system.codedom>
		<compilers>
			<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
				<providerOption name="CompilerVersion" value="v3.5"/>
				<providerOption name="WarnAsError" value="false"/></compiler>
			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
				<providerOption name="CompilerVersion" value="v3.5"/>
				<providerOption name="OptionInfer" value="true"/>
				<providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
	<system.net>
		<mailSettings>
			<smtp from="admin@connect2vendors.com">
				<network host="mail.connect2vendors.com" password="sf5500bb" userName="postmaster@connect2vendors.com"/>
			</smtp>
		</mailSettings>
	</system.net>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sinsoushAuthor Commented:
hemal, you are very smart and excellent at what you do!

Thank you very much for your quick and to the point solution...it works perfect!!!

Cheers,
Travis
0
 
sinsoushAuthor Commented:
Very well documented explanation...very helpful
0
 
hemaldesaiCommented:
U r most wellcome Travis,

u can reach me at hemal.desai@gmail.com any time.

if u need some materials to learn please let me know.

hemal
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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