ロールを使用してアクセスを制限したいクラス (DPCal_EventMove) のメソッドが 1 つあります。Global.asax.cs エラー ハンドラーとカスタム IHttpModule エラー ハンドラーの両方を使用して、未処理の例外をキャッチし、それらを GlobalExceptionHandler.aspx に Server.Transfer します。何らかの理由で、PricipalPermission で装飾されたメソッドによって発生した未処理の例外が、どちらのエラー ハンドラーにもルーティングされません。私の質問は次のとおりです。この例外はどこにルーティングされ、どのようにキャッチして処理するのですか?
public partial class DayView : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Do some stuff
}
[PrincipalPermission(SecurityAction.Demand, Role = "Investigator")]
[PrincipalPermission(SecurityAction.Demand, Role = "Administrator")]
protected void DPCal_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e)
{
// If no overlap, then save
int eventId = Convert.ToInt32(e.Value);
MembershipUser user = Membership.GetUser();
if (!CommonFunctions.IsSchedulingConflict(eventId, e.NewStart, e.NewEnd) &&
Page.User.HasEditPermission(user, eventId))
{
dbUpdateEvent(eventId, e.NewStart, e.NewEnd);
GetEvents();
DPCal.Update();
}
}
}
以下は、私の Global.asax.cs ファイルです。
public class Global : System.Web.HttpApplication
{
protected void Application_Error(object sender, EventArgs e)
{
Server.Transfer("~/GlobalExceptionHandler.aspx?ReturnUrl=" + Request.Path);
}
}
以下は、私のカスタム IHttpModule ハンドラーです。
public class UnhandledExceptionModule : IHttpModule
{
private HttpApplication _context;
private bool _initialized = false;
public void Init(HttpApplication context)
{
_context = context;
_initialized = true;
context.Error += new EventHandler(Application_Error);
}
public UnhandledExceptionModule()
{
_initialized = false;
}
public void Dispose()
{
if (_initialized)
_context.Dispose();
}
public void Application_Error(object sender, EventArgs e)
{
if (_initialized)
_context.Server.Transfer("~/GlobalExceptionHandler.aspx?ReturnUrl=" + _context.Request.Path);
}
}
GlobalExceptionHandler.aspx の Page_Load に達することはありません。