Monday 15 September 2014

c# - ASP.NET: UrlReferer has wrong value, interrogating in a static (webmethod) page called from jquery -


Can anyone help? I am trying to inquire with UrlReferer whcih which should contain Google.com but includes my current site. My web page is a standard HTML page and jquery calls are a static method such as

  [WebMethod] Public static zero ProcessTracking (string jsonString)  

In this method I do a standard lookup on request. Similar to the URLRFrror,

  string referrals domains = HTTPPointText Running request. URL Referrer.host;  

But it always includes my current domain, it was a little suspicious, so I created a standard asp.net page and did the same and without it 100 % Works. Issue ..

It seems that when my HTM page calls through my webmail (static) and inquires with UrlReferrer then always My current site comes back which is wrong.

Does anyone know how to work around?

I have session_start etc. in global.asax but no fixes.

Edit: How do I call a page from jquery in HTML

  $ Ajax ({type: "POST", Url: "MyService.aspx / ProcessTracking", data: jsonData, contentType: "application / json; charset = utf-8", data type: "json", async: true, success: Function (msg) {}, error: function (msg) {alert (error);}});  

This script is hosted on your page, right? In that case, the referrer will be your site.

If you want a referral for the page, then you have to give it as argument with your Ajax call; It will not be present in the HTTP header.

You can read the page referrer from the document.referrer property.


No comments:

Post a Comment