Wednesday, September 10, 2008

Force Windows Authentication popup (Firefox)

C sharp:

Response.ClearHeaders();
Response.AppendHeader("Cache-Control", "no-cache; private; no-store; must-revalidate; max-stale=0; post-check=0; pre-check=0; max-age=0"); // HTTP 1.1
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1
Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1
Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1
Response.Close();

Execute the following code on some action and browser will popup a dialog box for authentication

no-cache here refers to asp.net Session. If you remove it from the Cache-Control list, it will retain the Session variables.

No comments: