English 中文(简体)
How do Global.asax 具有约束力的事后请求活动发生吗?
原标题:How does Global.asax PostAuthenticateRequest event binding happen?

我如何使用<> PostAuthenticateRequest event of Global.asax? http://www.asp.net/security/tutorials/forms-authentication-configuration-and-advanced-topics-cs”rel=“nofollow”>this tutorial,并提到我必须使用 PostAuthenticateRequest activity. 当我加入全球时。 作为大事,它创建了两个档案,即标识和编码背后档案。 这里是密码背后档案的内容。

using System;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace authentication
{
    public class Global : System.Web.HttpApplication
    {    
        protected void Application_Start(object sender, EventArgs e)
        {    
        }

        protected void Session_Start(object sender, EventArgs e)
        {    
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {    
        }

        protected void Application_Error(object sender, EventArgs e)
        {    
        }

        protected void Session_End(object sender, EventArgs e)
        {    
        }

        protected void Application_End(object sender, EventArgs e)
        {    
        }
    }
}

Now when I type the

protected void Application_OnPostAuthenticateRequest(object sender, EventArgs e)

它得到成功呼吁。 我现在想知道“黎明”是如何的。 PostAuthenticateRequestompulsory to this Application_OnPostAuthenticateRequest methods? 我怎么能把方法改变到其他方法?

最佳回答

......,一个叫做Auto Activities teup的机制,也是你可以写的同样原因。

Page_Load(object sender, EventArgs e) 
{ 
} 

在您的代码背后,当页数时,将自动使用这种方法。

关于<代码>System.Web.Configuration.Pages Section.AutoEventWireup的MSDN说明 财产:

了解或确定一种价值,说明是否为伙伴关系开展活动。 互联网网页与事件处理功能自动连接。

在<代码>AutoEventWireup>上true时,处理人根据自己的姓名和签名,在经营时间自动受事件的约束。 每一次活动,都设有伙伴关系。 NET搜索一种根据模型<代码>Page_eventname()命名的方法,例如<编码>Page_Load(或Page_Init()。 ASP. 该网络首先研究的是具有典型活动手签名的超载(即,它具体指明了<代码>Object和-EventArgs参数)。 如果发现有这种签名的事件手,协会。 NET的超载数据没有参数。 http://stackoverflow.com/a/2059139/57428“>。

If you wanted to do it explicitly you would write the following instead

public override void Init()
{
    this.PostAuthenticateRequest +=
        new EventHandler(MyOnPostAuthenticateRequestHandler);
    base.Init();
}

private void MyOnPostAuthenticateRequestHandler(object sender, EventArgs e)
{
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签