ASP.NET MVC查找内容页面发送Ajax请求 [英] ASP.NET MVC find what page sent the Ajax request

查看:209
本文介绍了ASP.NET MVC查找内容页面发送Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施剖析了我们的网站,而我基本上只是使用的Application_BeginRequest计时器() Application_EndRequest()跟踪请求次数。

I'm implementing profiling for our site, and I'm basically just using timers in Application_BeginRequest() and Application_EndRequest() to track the request times.

的问题是,在 Application_EndRequest(),我可以通过 Request.RawUrl 获得Ajax请求的URL,但我怎么能得到哪些页面发送该请求?

The issue is that in Application_EndRequest(), I can get the Ajax request's URL by Request.RawUrl, but how can I get which page sent this request?

推荐答案

您可以检查 Request.UrlReferrer 来获取从中发出请求的页面,但请记住,有些浏览器可能不发送引用者在Ajax请求,你应该考虑这种情况下,您的code。

You can check Request.UrlReferrer to get the page from which the request originated but keep in mind that some browser may not send referer in ajax requests and you should account for this case in your code.


另外,你应该通过包含当前网址在所有Ajax调用额外的参数。


Alternatively, you should pass an additional parameter containing the current url in all your ajax calls.

这篇关于ASP.NET MVC查找内容页面发送Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆