tags:

views:

42

answers:

2

As identified in C # where this is requested a specific web page, I wonder if the request comes from an image <img src="http://www.mydomain.com/default.aspx?n=123" /> or if the request is directly through an http browser, for example when the client is actually accessing the page via a browser sample: http://www.mydomain.com/default.aspx?n=123

+1  A: 

See http://stackoverflow.com/questions/803027/finding-the-referring-url-that-brought-a-user-to-my-site.

You'll probably get more answers if you tag your question with ASP.NET.

No, it's not completely reliable. HTTP is in large part a cooperative protocol. That is, there are fields there that browsers can use to identify themselves and tell you where they're coming from, but nothing forces them to do it. The sad truth, unbelievable as it may seem, is that people might lie to you. They might say they're viewing your image from your Web page, when they really aren't. Or their browser might not tell you that it's viewing the image from your Web page. In general, the UrlReferrer thing works, but it can be defeated. Just as the browser identification string can be spoofed. We do the best that we can, and call it good enough.

Jim Mischel
I fixed the tag for them.
Steven Sudit
That is not, in fact none of these procedures is what I'm looking for. I will list the procedures that do not work with what you really want.Response.Write(Page.PreviousPage.ToString());Response.Write(Request.UrlReferrer.ToString());Response.Write(Context.Request.UrlReferrer.ToString());Response.Write(Request.ServerVariables["HTTP_REFERER"].ToString);
what I'm looking for truth would be something like the behavior that identifies whether the requested url arises when starting from an image, or originates from a different browser via http.
A: 

I would expect the Request.UrlReferrer to be null when the image src makes the request.

rick schott
Yes, but it could be null for other cases, as well. It's not reliable.
John Saunders
in this case that does not work even when an image is on a web page means that this page has an address but will always be a reference. UrlReferrer not work for what I need, please before you answer, read the whole question. Thank you.
Please be happy that people spend their free time answering your question.
rick schott