I have two pages namely www.abc.com/pg1.aspx
and www.abc.com/pg2.aspx
pg1.aspx
response.redirect("www.abc.com/pg2.aspx");
pg2.aspx
string url_refer = Request.UrlReferrer.ToString();
UrlReferrer
is working fine.
pg1.aspx
<a href='#' onclick=\"window.open('www.abc.com/pg2.aspx', 'windowname2', 'width=1014, height=709, screenX=1, left=1, screenY=1, top=1, status=no, menubar=no, resizable=no, toolbar=no'); return false;\">
pg2.aspx
string url_refer = Request.UrlReferrer.ToString();
UrlReferrer
is NULL
I googled for the solution. but none of them are leading to the solution i want.
My problem is if the window is with no menubar, status or toolbar, UrlReferrer
is NULL
if not, UrlReferrer
has the previous page's URL.
I also tried url_refer = Request.ServerVariables["HTTP_REFERER"].ToString();
instead of string url_refer = Request.UrlReferrer.ToString();
.
the result is the same.
Any solution?
I'm not sure.. but I found out..
Session is not working if we call a new page using Javascripts.
I was told that all session values are reset on a new page which is called using javascripts.
As an alternative for my question, I used QueryString.
I really don't want the users to see the URL but I already hide the URL with javascript.
So, I have no problem using querystring, right?
Does anyone hava a better solution?
I found this great workaround on a forum, and adapted it slightly.
Put this code at the top of your page:
...and then build your links like this:
What you're doing is creating an invisible
<a>
element, then using javascript to change that element's address, and programatically "click" it.My solution is to take it from "document.referrer"
The trick is to use location.href which does record the referer in IE.
There's no easy answer to this - in general, the
UrlReferrer
is a browser-specific behaviour. Chrome, for instance, can process this differently than Internet Explorer.If you are doing the referring yourself then you'll be best off passing a querystring parameter or using session state to identify the referring URL.