Reference: http://erlend.oftedal.no/blog/?blogid=55
<authentication mode="Forms" >
<forms loginUrl="~/admin/Login.aspx"></forms>
</authentication>
Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.
Showing posts with label C# Configuration Mananger. Show all posts
Showing posts with label C# Configuration Mananger. Show all posts
Saturday, April 5, 2008
Changing the default login page for use with LoginStatus control
Sometimes it is desirable to have a different default login page. For example, a simple site where administrators login at http://foo.com/admin/Login.aspx versus the standard http:foo.com/Login.aspx. The LoginStatus control will hyperlink back to the default login page. To change this default login page, change the web.config file as follows:
Thursday, March 27, 2008
Configure SQL Database for User Login
If you try and set up User Login without configuring the web.config file and try to login from a hosted site you might get an error similar to :" An attempt to attach an auto-named database for file C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\WebSite1\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. "
To configure it for User Login, I first added the user database to the SQL server using this method.
Next, I changed the web.config file to include:
To configure it for User Login, I first added the user database to the SQL server using this method.
Next, I changed the web.config file to include:
Just change the myX fields to your fields. And now your configuration manager should work to add users and roles.
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=my.host.net;Database=myDatabase;uid=myUserId;pwd=myPassword" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authentication mode="Forms" />
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServersm" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="3" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" maxInvalidPasswordAttempts="3"/>
</providers>
</membership>
<roleManager enabled="true" />
Tuesday, February 19, 2008
Using Web.config hash for variables using add, key, and value
Use configuration (web.config) hash to set variables. First, there is the web.config file section: ...
Now in the code-behind I can set a Hyperlink variable as follows:
<configuration>
<appSettings>
<add key="fooLink" value="http://www.foo.htm"/>
</appSettings>
</configuration>
HyperLinkFoo.NavigateUrl = ConfigurationManager.AppSettings["fooLink"].ToString().ToLower();
Subscribe to:
Posts (Atom)