JG Vimalan's Blog

It is all about coding!

Force Login dialog display

 To force login dialog in your asp.net application, follow the following steps,

1. Open global.asax .cs

2. Add the Application_AuthenticateRequest event

 3. Add the following code as shown below,

//this event will get hit after verifying with the AD

 protected void Application_AuthenticateRequest(object sender, EventArgs e){

. . . //your logic here

var loggedUser = Request.ServerVariables[“Logon_User”].ToLower(); //get the logged in user… //your logic here
//now force login dialog to display

Response.AppendHeader(“WWW-Authenticate”, “Basic”); 

Response.StatusCode = 401;

Response.End();

}

Advertisements

December 30, 2009 - Posted by | ASP.NET

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: