【问题标题】:Intercepting asp.net ajax webmethod拦截asp.net ajax webmethod
【发布时间】:2013-06-29 12:06:21
【问题描述】:

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

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

【问题讨论】:

  • 之前和之后你想做什么?

标签: asp.net ajax webmethod


【解决方案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. domain.com/dfault.aspx/GetMessage;
if(ss=="http://domain.com/dfault.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. domain.com/dfault.aspx/GetMessage;;

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

【讨论】:

  • 感谢您的回答,这将对我有所帮助,但是如果我想拦截每个网络方法,有什么办法吗?因为这个解决方案我必须写很多 if else 条件。有什么方法可以检测是 webmethod 还是正常的页面请求?
【解决方案2】:

你可以试试fiddlerHTTtamper

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-28
    • 2013-05-24
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    相关资源
    最近更新 更多