0
我有一個公共(無身份驗證)網站,除了一個頁面需要驗證。這工作正常。重定向到asp.net中不工作的自定義禁止頁面
受保護的頁面是一個具有以下的web.config文件夾中:
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow roles="Warehouse" />
<deny users="*" />
</authorization>
<customErrors mode="RemoteOnly" defaultRedirect="../WebForbidden.aspx">
<!--<error statusCode="403" redirect="WebForbidden.aspx" />
<error statusCode="404" redirect="FileNotFound.htm" />-->
</customErrors>
</system.web>
</configuration>
而該頁面的主文件有以下幾點:
protected void Page_Init(object sender, EventArgs e)
{
CheckLogged();
}
public bool CheckLogged()
{
bool status = false;
if (Session["Username"] == null)
{
FormsAuthentication.SignOut();
Response.Redirect("../WebForbidden.aspx");
//FormsAuthentication.RedirectToLoginPage();
}
else
{
status = true;
}
return status;
}
而且我有個WebForbidden.aspx頁面在網站的根目錄中。
現在,每次我嘗試直接進入受保護的頁面(這是禁止,除非經過身份驗證),而不是顯示禁止頁面,則會顯示一個錯誤:The resource cannot be found
,當然,該網站正嘗試重定向到登錄頁面,這不存在。
任何幫助將不勝感激。
這工作真棒!謝謝! – Somebody 2013-02-15 20:05:36