拦截asp.net ajax webmethod

问题描述 投票:0回答:2

有没有办法拦截asp.net ajax webmethods(aspx页面静态方法)?

我想在请求到达方法之前以及发送响应之后进行拦截。

asp.net ajax webmethod
2个回答
1
投票

在global.asax文件中使用

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        //before method colling
        string ss = HttpContext.Current.Request.Url.ToString();//use if it is equal to your page webmethod url  i.e. example.com/default.aspx/GetMessage;
        if(ss == "http://example.com/default.aspx/GetMessage")
        {
            // do your work here
        }
    }

    protected void Application_EndRequest(Object sender, EventArgs e)
    {
        //after method colling
        string ss = HttpContext.Current.Request.Url.ToString();// use if  it is equal to your page webmethod i.e. example.com/default.aspx/GetMessage;

        if(ss=="http://example.com/default.aspx/GetMessage")
        {
            // do your work here
        }
    }

-1
投票

你可以尝试fiddlerHTTtamper

© www.soinside.com 2019 - 2024. All rights reserved.