ASP.Net 2.0 User Management System.
I could not believe how easy this was to get working, well I was shocked at least, so without
any further introduction here goes:
How to creating the ASP NET User and Role account
If like me you have a limited number of SQL databases available to you from
your host ISP, you will
probably be saying to yourself "but I want to create the tables and schema's inside
of an existing database". Well this is not a problem.
Go to the command line and run aspnet_regsql.exe without any parameters,
this will bring up a Graphical User Interface (GUI) allowing you to point to a SQL
server hosted by your ISP, and allow you to login to the server using SQL authentication,
and then select an existing database. For further details refer to the Microsoft
article - ASP.NET SQL Server Registration Tool

Web.Config settings
Configuring your web.config file to use the database. Note there are a few
issues that you should be aware off:
-
The ApplicationPath defaults to blank
and therefore the location of your application
- When you move or deploy the application,
this will mean that the location has changed and the web site can no longer find
the users / roles / membership for the new application.
For a detailed description
please refer to:
Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers
All of the following tags are within the <configuration> </configuration>
tags.
Connection String to the SQL database
<connectionstrings>
<Add
name="AspUserMangement"
connectionstring="Data Source=123.123.123.123;
Initial Catalog=MyOwnDataBaseName;
Persist Security Info=True;
User ID=jtbarton;
Password=GuessMe;"
/>
</connectionstrings>
User and Role Membership
<system.web>
<membership defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="AspUserMangement"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
passwordFormat="Hashed"
applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="SqlProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName="jtbarton.com"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="All" >
<providers>
<clear/>
<add
name="SqlProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="AspUserMangement"
applicationName="/" />
</providers>
</roleManager>
</system.web>
Email configuration
This will vary, but for my host all I need to provide is<system.net>
<mailSettings>
<smtp deliveryMethod="network"> <network host="mail.yourdomain.com" port="2525" username="TheUser" password="ThePassword" />
</smtp>
</mailSettings>
</system.net>
What's Next
Surprisingly very little, just drop on the controls from the Toolbox Login section,
and they will work out of the box.
Want me to show you,
click here
to see login control samples in action, but there is no code to see, promise, all
this functionality is straight out of the box, well toolbox.
Where to find additional information
This article is based on the information provided by
4GuysFromRolla.com, Click here for the article
Examining ASP.NET 2.0's Membership, Roles, and Profile
By Scott Mitchell. There are 4 parts to this article which further go on to
explain about role management, and improving the login experience. My personal
thanks go out to Scott for creating such a fantastic article.
Other useful links related to Role and User management
|