Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Cookieless ASP.NET forms authentication

, 25 Aug 2002
They say it is not possible to use cookieless forms authentication in .NET. Well it is, and relatively easy to accomplish!
cookieless_src.zip
samplecookieless
Global.asax
samplecookieless.csproj.webinfo
samplecookieless.vsdisco
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

namespace samplecookieless 
{
	/// <summary>
	/// Summary description for Global.
	/// </summary>
	public class Global : System.Web.HttpApplication
	{
		public Global()
		{
			InitializeComponent();
		}	
		
		protected void Application_Start(Object sender, EventArgs e)
		{

		}
 
		protected void Session_Start(Object sender, EventArgs e)
		{

		}

		protected void Application_BeginRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_EndRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_AuthenticateRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_Error(Object sender, EventArgs e)
		{

		}

		protected void Session_End(Object sender, EventArgs e)
		{

		}

		protected void Application_End(Object sender, EventArgs e)
		{

		}
			
		#region Web Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			// 
			// Global
			// 
			this.AcquireRequestState += new System.EventHandler(this.Global_AcquireRequestState);

		}
		#endregion

		private void Global_AcquireRequestState(object sender, System.EventArgs e)
		{
			if((string)Session["cool"] != "piglet")
			{
				if(!Request.Path.EndsWith("login.aspx"))
				{					
					Response.Redirect("login.aspx");
					Response.End();
				}
			}
		}
	}
}

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

Share

About the Author

brutal

Hungary Hungary
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 26 Aug 2002
Article Copyright 2002 by brutal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid