<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Handle windows authentication login popups Cancel click' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Handle windows authentication login popups Cancel click' posted on the 'ASP.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 15:10:39 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 15:10:39 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Handle windows authentication login popups Cancel click</title>
      <link>http://www.programmersheaven.com/mb/ASPNET/419499/419499/handle-windows-authentication-login-popups-cancel-click/</link>
      <description>Hi!&lt;br /&gt;
&lt;br /&gt;
I have simple web application called App that is secured with Windows Authentication. I have set identity impersonate to true in web.config. There is only one page (Default.aspx) in App directory. When user enters the site ex.: &lt;a href="http://localhost/App"&gt;http://localhost/App&lt;/a&gt; the login window pops up. When user clicks Cancel, IIS redirects to page with an error 401.2. I want to redirect to &lt;a href="http://localhost/App/app_start/login.aspx."&gt;http://localhost/App/app_start/login.aspx.&lt;/a&gt; App_start is an aplication that is secured with Forms Authentication. I tried to handle programmatically the redirection by adding Application_EndRequest method in Global.asax file. But when user clicks Cancel the Application_EndRequest is not being fired. When user successfully logs in the method is being fired. Is there any way to handle error 401.2 programmatically or maybe in a different way?&lt;br /&gt;
&lt;br /&gt;
Application_EndRequest code:&lt;br /&gt;
&lt;br /&gt;
if (Response.StatusCode == 401)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
     Response.Clear();&lt;br /&gt;
&lt;br /&gt;
     Response.Write("You don't have access to content.");&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The web.config file of App application:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;system.web&amp;gt;&lt;br /&gt;
    &amp;lt;compilation debug="true" targetFramework="4.0" /&amp;gt;&lt;br /&gt;
    &amp;lt;authentication mode="Windows" /&amp;gt;&lt;br /&gt;
    &amp;lt;identity impersonate="true" /&amp;gt;&lt;br /&gt;
    &amp;lt;machineKey decryptionKey="hidden from forum" validationKey="hidden from forum" /&amp;gt;&lt;br /&gt;
  &amp;lt;/system.web&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thanks for help.&lt;br /&gt;
&lt;br /&gt;
Sincerely,&lt;br /&gt;
&lt;br /&gt;
Peter.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ASPNET/419499/419499/handle-windows-authentication-login-popups-cancel-click/</guid>
      <pubDate>Wed, 03 Nov 2010 01:48:03 -0700</pubDate>
      <category>ASP.NET</category>
    </item>
  </channel>
</rss>