Reputation: 16236
My web service wants to know what is the page url of the caller.
I checked the HttpReq -> Url it is the actual web service Url. Also the HttpReq -> UrlReferrer but it is not right, neither.
Is it possible to find out the caller page url from server side at all? Or do I have to pass in the url via service dto?
Thanks for your help :)
Upvotes: 1
Views: 660
Reputation: 34846
Pass the page URL as a parameter to your web service by using the JavaScript document.location.href
notation, like this:
$.ajax({
type: "POST",
url: "YourPage.aspx/DoSomething",
data: "{'pageUrl' : window.location.href}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
}
});
Then you can handle the pageUrl
value in your service code.
Upvotes: 1
Reputation: 120400
If, for whatever reason, UrlReferrer doesn't work out for you then... the page where the request came from knows what its address is, right? Why not supply this data to the javascript that served the Ajax request, so you can send it up with the Ajax request?
Upvotes: 2