using ASP.NET MVC, is there a way to capture all POST requests regardless of URL to a host? -
i'm having trouble debugging mvc app i'm expecting relying part post to.
is there easy way configure mvc 4 application intercept post requests can see url trying post , response is?
normally, global filter want. however, since not trigger until after route determined, might not in situation.
one thing try add application_beginrequest method in global.asax. doesn't have do anything. set breakpoint in it, , inspect request.apprelativecurrentexecutionfilepath (or other members of request) see inbound path is.
protected void application_beginrequest() { if (request.httpmethod.equals("post", stringcomparison.invariantcultureignorecase)) { // breakpoint here } } a "global filter" preferred method injecting behaviors, etc. pipeline. mvc implements of these, , can extend or implement own.
one concrete example implemented last year: client site has feature expire password. great; works fine, when user changes when told so. figured out navigate portion of site, , didn't prompt again until next time logged in. added global filter checked whether password expired (and whether we'd checked in session) and, if so, redirected "change password" screen. after changing it, return wherever before.
here's drawback this, though, figuring out routing or binding issue: routing engine has evaluated request before global filter can it. if fails identify target action, filter won't hit. in case, lower-level feature application_beginrequest realistic option.
Comments
Post a Comment