Solved

Getting an Error page to work with a 401.2 error

Posted on 2012-12-27
6
384 Views
Last Modified: 2012-12-28
I have a website set up that has a web.config in the root directory.  There are also 3 sub directories that each have a web.config that is used for permissions. My problem is that when I try to get the custom errors to work.  I have the following code in the root level web.config.
<system.web>
    <customErrors mode="On" defaultRedirect="Error.htm" />
    <authentication mode="Windows"/>
    <authorization>
      <deny users="?" />
    </authorization>

Open in new window


I have the following code in one of the sub directories:
<?xml version="1.0"?>
<configuration>
  <system.web>
    <authorization>
      <allow users="ADS\Smith"/>
      <allow users="ADS\Jones"/>
      <deny users="*"/>
    </authorization>
    <customErrors mode="On" defaultRedirect="Error.htm">
      <error statusCode="401" redirect="Admin401.htm" />
    </customErrors>
  </system.web>
</configuration>

Open in new window


 When I receive a general error the Error.htm page works as it should.  What I am trying to get to work is the 401.2 error page. In the subfolder the web.config looks like this:
My 401 error
How do I get the 401.2 error to use my Admin401.htm?
0
Comment
Question by:us1975mc
  • 3
  • 3
6 Comments
 

Author Comment

by:us1975mc
ID: 38723734
Forgot to mention that just before I get the 401 error I get the Windows Logon:
Windows Security Logon
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 38723774
One answer is here:
http://weblogs.asp.net/gurusarkar/archive/2010/01/12/redirect-unauthorized-users-to-access-denied-page-instead-of-login-page.aspx

Another way to do this is to go into the properties for the site in IIS, and on the Custom Errors tab, change which page is displayed for the 401.2 error.
0
 

Author Comment

by:us1975mc
ID: 38724273
paulmacd,
I tried both with no success.  When I entered the code:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Request.IsAuthenticated AndAlso Not String.IsNullOrEmpty(Request.QueryString("ReturnUrl")) Then
                Response.Redirect("~/TechError.aspx")
            End If
        End If
    End Sub

Open in new window

It does not seem to even see this.  I get the same Sign In:
Sign Inand then I get the same error:
Error 401When I went to the server administrators and they placed the error page on the property for the site in the IIS I received the following error:
Page Error
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 38724295
Okay, those are two different issues.  You're being asked to log in to the domain (the Windows Security dialog) because you have anonymous access turned off and/or you have permissions set so the web user account (IUSR_whatever) doesn't have permissions to the .aspx page.

The second issue ("the website cannot display the page") could be anything.  Can you try to recreate the problem while viewing the page(s) in IIS?  You should get a more descriptive error message that way.
0
 

Author Closing Comment

by:us1975mc
ID: 38726855
Thanks paulmacd,

It took a little while but it finally came through.

Thanks!!!
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 38726867
Happy to help.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question