Click here to Skip to main content
15,891,689 members
Articles / Web Development / ASP.NET

Custom Authentication provider by implementing IHttpModule, IPrincipal and IIdentity

Rate me:
Please Sign up or sign in to vote.
4.55/5 (41 votes)
2 Nov 20033 min read 360.1K   10.5K   159  
An article on writing Custom Authentication provider in ASP.NET
<%@ Page language="c#" Codebehind="Home.aspx.cs" AutoEventWireup="false" Inherits="CustomAuthenticationDemo.Home" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>Home</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<LINK href="style.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body>
		<form id="Home" method="post" runat="server">
			<table width="100%">
				<tr valign="center" height="300">
					<td valign="center">
						<table border="1" cellpadding="0" bordercolor="peru" bgcolor="khaki" align="center" width="60%">
							<tr>
								<td align="right" width="60%">User Name from the HTTP Context:</td>
								<td>
									<asp:Label id="user1" runat="server"></asp:Label></td>
							</tr>
							<tr>
								<td align="right">User Name from the Thread.CurrentPrincipal:</td>
								<td>
									<asp:Label id="user2" runat="server"></asp:Label></td>
							</tr>
							<tr>
								<td align="right">Is in Administrator Role:</td>
								<td>
									<asp:Label id="role" runat="server"></asp:Label></td>
							</tr>
							<tr>
								<td colspan="2">&nbsp;<font size="2" color="teal"> The above User name is retrieved 
										using CustomAuthenticationModule. On Login the User details are stored in 
										encrypted form in a cookie and then retrieved form the cookie on each Request.</font></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions