我正在使用位于http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspx的 SuppressFormsAuthenticationRedirectModule来防止重定向某些 HTTP 401状态并改为显示自定义页面。
但是,我将 Object Moved Here 作为输出。如何改为显示我的自定义页面?
页面如下
<%@ Page Title="Unauthorized" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeBehind="UnauthorizedError.aspx.vb" Inherits="WebFormsTemplate.UnauthorizedError" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<h2>Unauthorized</h2>
You do not have permission to view this page.
</asp:Content>
背后的代码
Imports System.Net
Imports Appahoo.Web.WebForms
Public Class UnauthorizedError
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SuppressFormsAuthenticationRedirectModule.SuppressAuthenticationRedirect(Me.Context, False)
Me.Response.StatusCode = HttpStatusCode.Unauthorized
End Sub
End Class