一部のHTTP401のリダイレクトを防ぐために、 http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspxにあるSuppressFormsAuthenticationRedirectModuleを使用しています。ステータスを設定し、代わりにカスタムページを表示します。
ただし、出力としてObjectMovedHereを取得しています。代わりにカスタムページを表示するにはどうすればよいですか?
次のようなページ
<%@ 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