Getting an Error page to work with a 401.2 error

Posted on 2012-12-27
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.
    <customErrors mode="On" defaultRedirect="Error.htm" />
    <authentication mode="Windows"/>
      <deny users="?" />

Open in new window

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

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?
Question by:us1975mc
  • 3
  • 3

Author Comment

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

Expert Comment

by:Paul MacDonald
ID: 38723774
One answer is here:

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.

Author Comment

ID: 38724273
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
            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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

LVL 34

Accepted Solution

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.

Author Closing Comment

ID: 38726855
Thanks paulmacd,

It took a little while but it finally came through.

LVL 34

Expert Comment

by:Paul MacDonald
ID: 38726867
Happy to help.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now