I was wondering what is the best way (if at all possible) to determine on the server side if a given HttpRequest was sent via ajax?
views:
91answers:
3
+2
A:
An XMLHttpRequest appears just like any other browser request. As far as I know, there's no way to distinguish them, unless the XMLHttpRequest is deliberately setting headers to identify itself as such.
Tony
2009-01-09 15:28:16
+1
A:
This may or may not help you out, but you can at least determine if the postback is an asynchronous one (meaning that it was likely sent via ajax). You can do this via the following:
if (sm1.IsInAsyncPostBack)
{
//code here
}
The sm1 referenced above would be provided for with this:
<asp:ScriptManager id="sm1" runat="server" />
alex
2009-01-09 15:36:40
+1
A:
Here is similar but more detailed information on this subject:
How to determine whether an Asynchronous Partial Postback has occurred on page?
Roboblob
2009-07-04 23:18:28