Users are not redirected to the page that contains the custom error message when you design an application that uses impersonation in ASP.NET (902239)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
SYMPTOMSWhen you design an application that uses impersonation in Microsoft ASP.NET, users are not redirected to the page that contains the custom error message. You implement impersonation by using the following code.
<authentication mode="Windows" />
<identity impersonate="true" userName="Domain\User" password="Password"/>
This problem occurs when you use the following code in the Web.config file.
<customErrors mode="On" >
<error statusCode="401" redirect="unauthorized.htm" />
</customErrors> WORKAROUNDTo work around this problem, redirect to the custom error page by using the following code in the Global.asax file. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' This exception is raised when an error occurs.
Dim ex As Exception = Server.GetLastError().GetBaseException()
If ex.GetType Is Type.GetType("System.UnauthorizedAccessException") Then
Server.ClearError()
Response.Redirect("unauthorized.htm")
End If
End Sub
Modification Type: | Major | Last Reviewed: | 6/13/2005 |
---|
Keywords: | kbtshoot kbprb KB902239 kbAudDeveloper |
---|
|