I am retrofitting a central login application and want to be able to read
the Request.ServerVariables["HTTP_REFERER"] so that when they have logged
on, I can send them back to wherever they were trying to go..
If you try to load a legacy ASP app, I do this:
If Len(SessionID) <> 40 Then
Response.Redirect "/WAS/Default.aspx?AppCode=2400"
End If
On Default.aspx, I go so far as do this:
foreach (string s in Request.ServerVariables.AllKeys)
{
Response.Write(s + "=[" + Request.ServerVariables[s] + "]<br>");
}
HTTP_REFERER is blank. If I had a <a href="Default.aspx">click</a> on that
same page, then referer fills in. Why can I not see the HTTP_REFERER in this
scenario??
Also, I tried instead of the Response.Redirect, doing something like:
<script>
window.location.href='/WAS/Default.asp?AppCode=2400';
</script>
Just in case Response.Redirect sends some wacky header that is throwing off
ASP.NET??
I'm really jammed up and running WAY behind - any insight greatly
appreciated, thanks!! 15 15372
"Drebin" <th*******@hotmail.com> wrote in message
news:QF*******************@newssvr31.news.prodigy. com... I am retrofitting a central login application and want to be able to read the Request.ServerVariables["HTTP_REFERER"] so that when they have logged on, I can send them back to wherever they were trying to go..
If you try to load a legacy ASP app, I do this:
If Len(SessionID) <> 40 Then Response.Redirect "/WAS/Default.aspx?AppCode=2400" End If
On Default.aspx, I go so far as do this:
foreach (string s in Request.ServerVariables.AllKeys) { Response.Write(s + "=[" + Request.ServerVariables[s] + "]<br>"); }
HTTP_REFERER is blank. If I had a <a href="Default.aspx">click</a> on that same page, then referer fills in. Why can I not see the HTTP_REFERER in this scenario??
Also, I tried instead of the Response.Redirect, doing something like:
<script> window.location.href='/WAS/Default.asp?AppCode=2400'; </script>
Just in case Response.Redirect sends some wacky header that is throwing off ASP.NET??
I'm really jammed up and running WAY behind - any insight greatly appreciated, thanks!!
The Referrer header isn't guaranteed to be there. Your code will have to be
able to handle that case.
-----
John Saunders
A value returned by a click event is the only way to
populate the HTTP_REFERER variable with data.
--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"John Saunders" <jo**************@hotmail.com> wrote in message
news:Ox****************@TK2MSFTNGP14.phx.gbl... "Drebin" <th*******@hotmail.com> wrote in message news:QF*******************@newssvr31.news.prodigy. com...I am retrofitting a central login application and want to be able to read the Request.ServerVariables["HTTP_REFERER"] so that when they have
logged on, I can send them back to wherever they were trying to go..
If you try to load a legacy ASP app, I do this:
If Len(SessionID) <> 40 Then Response.Redirect "/WAS/Default.aspx?AppCode=2400" End If
On Default.aspx, I go so far as do this:
foreach (string s in Request.ServerVariables.AllKeys) { Response.Write(s + "=[" + Request.ServerVariables[s] + "]<br>"); }
HTTP_REFERER is blank. If I had a <a href="Default.aspx">click</a> on
that same page, then referer fills in. Why can I not see the HTTP_REFERER in this scenario??
Also, I tried instead of the Response.Redirect, doing something like:
<script> window.location.href='/WAS/Default.asp?AppCode=2400'; </script>
Just in case Response.Redirect sends some wacky header that is throwing off ASP.NET??
I'm really jammed up and running WAY behind - any insight greatly appreciated, thanks!! The Referrer header isn't guaranteed to be there. Your code will have to
be able to handle that case.
----- John Saunders
But I've used this zillions of times with traditional ASP. For example, if
you navigate to /App1/ or /App2/ or /App3/ - they all check for the
existence of a cookie, if it's not there it redirects you to /Login/ - after
that app has authenticated you, it sends you back from whence you came!!
I understand there is the exclusively .NET alternative of doing Forms
authentication, but these apps are traditional ASP. Why does this no longer
work???????
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Oc**************@TK2MSFTNGP14.phx.gbl... A value returned by a click event is the only way to populate the HTTP_REFERER variable with data.
-- <%= Clinton Gallagher, "Twice the Results -- Half the Cost" Architectural & e-Business Consulting -- Software Development NET cs*********@REMOVETHISTEXTmetromilwaukee.com URL http://www.metromilwaukee.com/clintongallagher/
"John Saunders" <jo**************@hotmail.com> wrote in message news:Ox****************@TK2MSFTNGP14.phx.gbl... "Drebin" <th*******@hotmail.com> wrote in message news:QF*******************@newssvr31.news.prodigy. com... >I am retrofitting a central login application and want to be able to >read > the Request.ServerVariables["HTTP_REFERER"] so that when they have logged > on, I can send them back to wherever they were trying to go.. > > If you try to load a legacy ASP app, I do this: > > If Len(SessionID) <> 40 Then > Response.Redirect "/WAS/Default.aspx?AppCode=2400" > End If > > On Default.aspx, I go so far as do this: > > foreach (string s in Request.ServerVariables.AllKeys) > { > Response.Write(s + "=[" + Request.ServerVariables[s] + "]<br>"); > } > > HTTP_REFERER is blank. If I had a <a href="Default.aspx">click</a> on that > same page, then referer fills in. Why can I not see the HTTP_REFERER in > this > scenario?? > > Also, I tried instead of the Response.Redirect, doing something like: > > <script> > window.location.href='/WAS/Default.asp?AppCode=2400'; > </script> > > Just in case Response.Redirect sends some wacky header that is throwing > off > ASP.NET?? > > I'm really jammed up and running WAY behind - any insight greatly > appreciated, thanks!!
The Referrer header isn't guaranteed to be there. Your code will have to be able to handle that case.
----- John Saunders
But I've used this zillions of times with traditional ASP. For example, if
you navigate to /App1/ or /App2/ or /App3/ - they all check for the
existence of a cookie, if it's not there it redirects you to /Login/ - after
that app has authenticated you, it sends you back from whence you came!!
I understand there is the exclusively .NET alternative of doing Forms
authentication, but these apps are traditional ASP. Why does this no longer
work???????
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Oc**************@TK2MSFTNGP14.phx.gbl... A value returned by a click event is the only way to populate the HTTP_REFERER variable with data.
-- <%= Clinton Gallagher, "Twice the Results -- Half the Cost" Architectural & e-Business Consulting -- Software Development NET cs*********@REMOVETHISTEXTmetromilwaukee.com URL http://www.metromilwaukee.com/clintongallagher/
"John Saunders" <jo**************@hotmail.com> wrote in message news:Ox****************@TK2MSFTNGP14.phx.gbl... "Drebin" <th*******@hotmail.com> wrote in message news:QF*******************@newssvr31.news.prodigy. com... >I am retrofitting a central login application and want to be able to >read > the Request.ServerVariables["HTTP_REFERER"] so that when they have logged > on, I can send them back to wherever they were trying to go.. > > If you try to load a legacy ASP app, I do this: > > If Len(SessionID) <> 40 Then > Response.Redirect "/WAS/Default.aspx?AppCode=2400" > End If > > On Default.aspx, I go so far as do this: > > foreach (string s in Request.ServerVariables.AllKeys) > { > Response.Write(s + "=[" + Request.ServerVariables[s] + "]<br>"); > } > > HTTP_REFERER is blank. If I had a <a href="Default.aspx">click</a> on that > same page, then referer fills in. Why can I not see the HTTP_REFERER in > this > scenario?? > > Also, I tried instead of the Response.Redirect, doing something like: > > <script> > window.location.href='/WAS/Default.asp?AppCode=2400'; > </script> > > Just in case Response.Redirect sends some wacky header that is throwing > off > ASP.NET?? > > I'm really jammed up and running WAY behind - any insight greatly > appreciated, thanks!!
The Referrer header isn't guaranteed to be there. Your code will have to be able to handle that case.
----- John Saunders
"Drebin" <th*******@hotmail.com> wrote in message
news:q4*****************@newssvr19.news.prodigy.co m... But I've used this zillions of times with traditional ASP. For example, if you navigate to /App1/ or /App2/ or /App3/ - they all check for the existence of a cookie, if it's not there it redirects you to /Login/ - after that app has authenticated you, it sends you back from whence you came!!
I understand there is the exclusively .NET alternative of doing Forms authentication, but these apps are traditional ASP. Why does this no longer work???????
Because you never tested adequately enough to realize that it wasn't
actually working all the time.
You can't depend on the browser to do everything you want it to do. The
browser sets the Referrer header, or else decides not to. If you always want
the information you were getting in HTTP_REFERRER, then you need to include
it as a query string parameter or post it from a hidden field or send it in
a cookie:
on sender.aspx:
<a href="sent.aspx?referrer=sender.aspx">
--
John Saunders
John,
Thanks - but no, there are a couple of apps that have THOUSANDS of users and
have been running for a couple years and I've never had a single problem
(using this technique in ASP)!!!
The reason why your alternative isn't ideal, is my method handles if someone
went to a particular url. For example, if you tried to navigate to: http://someserver/someapp/InvoiceDet...othervars=crap
After you've been validated, I just Response.Redirect you back to that ugly
URL. I don't have to worrry about URL Encoding the path, etc.. it's doing
double the work. I *KNOW* that on this particular page, the user will always
be coming from another web app.
Philosophy aside, this was something that used to work and is reasonable to
expect to work in .NET - and I'm just trying to get to the bottom of *why*
it doesn't work or if there is an equivalent (aside from manually passing
the URL)?
Thanks!
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:OK**************@tk2msftngp13.phx.gbl... "Drebin" <th*******@hotmail.com> wrote in message news:q4*****************@newssvr19.news.prodigy.co m... But I've used this zillions of times with traditional ASP. For example,
if you navigate to /App1/ or /App2/ or /App3/ - they all check for the existence of a cookie, if it's not there it redirects you to /Login/ - after that app has authenticated you, it sends you back from whence you came!!
I understand there is the exclusively .NET alternative of doing Forms authentication, but these apps are traditional ASP. Why does this no longer work??????? Because you never tested adequately enough to realize that it wasn't actually working all the time.
You can't depend on the browser to do everything you want it to do. The browser sets the Referrer header, or else decides not to. If you always
want the information you were getting in HTTP_REFERRER, then you need to
include it as a query string parameter or post it from a hidden field or send it
in a cookie:
on sender.aspx: <a href="sent.aspx?referrer=sender.aspx">
-- John Saunders
"Drebin" <th*******@hotmail.com> wrote in message
news:q0*****************@newssvr17.news.prodigy.co m... John,
Thanks - but no, there are a couple of apps that have THOUSANDS of users and have been running for a couple years and I've never had a single problem (using this technique in ASP)!!!
"It's worked for years" is not the same thing as "we tested all functions
under all conditions and they all worked".
The reason why your alternative isn't ideal, is my method handles if someone went to a particular url. For example, if you tried to navigate to:
http://someserver/someapp/InvoiceDet...othervars=crap
After you've been validated, I just Response.Redirect you back to that ugly URL. I don't have to worrry about URL Encoding the path, etc.. it's doing double the work. I *KNOW* that on this particular page, the user will always be coming from another web app.
Philosophy aside, this was something that used to work and is reasonable to expect to work in .NET - and I'm just trying to get to the bottom of *why* it doesn't work or if there is an equivalent (aside from manually passing the URL)?
I'm sorry, I thought that had been made clear. HTTP_REFERRER comes from the
Referrer header in the request. If the browser or other user agent on the
clientdoesn't set the Referrer header, then you won't be able to read it on
the server.
You'll need to find out under what circumstances the browser is not setting
the Referrer header, then see if you can narrow it down: is it always sent
by one browser or browser version but not by another? Is it not being sent
for some buttons or links but is being sent for the others?
At any rate, unless you control the clients, you can't mandate that the
browser always send you this particular header. This is why you should have
a "Plan B".
John Saunders
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP15.phx.gbl... I'm sorry, I thought that had been made clear. HTTP_REFERRER comes from
the Referrer header in the request. If the browser or other user agent on the clientdoesn't set the Referrer header, then you won't be able to read it
on the server.
You'll need to find out under what circumstances the browser is not
setting the Referrer header, then see if you can narrow it down: is it always sent by one browser or browser version but not by another? Is it not being sent for some buttons or links but is being sent for the others?
At any rate, unless you control the clients, you can't mandate that the browser always send you this particular header. This is why you should
have a "Plan B".
This is a completely captive audience, a corporate intranet application -
ALL clients (without a single exception) are WinXP Pro, IE 6 and I
absolutely control *how* a user gets to this site, it will always have a
referer..... well... should have one I can read!!
This isn't so much a browser compatibility problem, these are the same
workstations trying to do the same thing - the difference being that this is
an ASP.NET trying to read HTTP_REFERER instead of ASP
And this is consistently NOT working, all the time and from several
different machines.
Thanks though...
"Drebin" <th*******@hotmail.com> wrote in message
news:hb*****************@newssvr16.news.prodigy.co m... This is a completely captive audience, a corporate intranet application - ALL clients (without a single exception) are WinXP Pro, IE 6 and I absolutely control *how* a user gets to this site, it will always have a referer..... well... should have one I can read!!
This isn't so much a browser compatibility problem, these are the same workstations trying to do the same thing - the difference being that this is an ASP.NET trying to read HTTP_REFERER instead of ASP
And this is consistently NOT working, all the time and from several different machines.
I'm sorry, but you're probably wrong.
You seem to be suggesting that IE6 always puts a Referrer header on every
request, but that ASP.NET is incapable of reading it, whereas ASP can read
it. That seems unlikely.
If you can look at the requests with a network monitor of some kind, you
would be able to confirm whether or not the Referrer header is being sent.
You could also take a look at Request.Headers to see if it's there.
If the header is reaching ASP but not ASP.NET, then the question is why not?
Are ASP and ASP.NET on different machines (so that some network, proxy or
firewall issue could be causing the problem). Are there ISAPI modules or
HttpModules set up for ASP.NET which are not set up for ASP?
Also, you should get back to basics on this one. Create a trivial web site
(WebApplication1.aspx) and see if it receives the header. If it doesn't,
then you'll know that the reason has nothing to do with the application. If
it does, then you'll know that the reason has to do with your application or
its setup.
Also, does this fail on development machines, or just production?
-----
John Saunders
"John Saunders" <jo**************@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP15.phx.gbl... If it does, then you'll know that the reason has to do with your application or its setup.
BINGO!! And we've come full circle. This works with ASP to ASP, but not ASP
to ASP.NET and to be clear, if you Response.Redirect from an ASP page to
another one (I wrote, with nothing special) - I can absolutely, positively
gaurantee referer will be filled in. I have used this method dozens of time
without a single incident of failure. I would bet a months salary on it*.
This is a controlled/internal/intranet environment.
Also, does this fail on development machines, or just production?
I've only done this on one machine.
All I'm asking - let me be clear, does anyone know anything that is handled
differently with ASP.NET in regards to the HTTP_REFERER??? thanks
*please note, salary will not really be bet - expression used for emphasis
> This works with ASP to ASP, but not ASP to ASP.NET and to be clear, if you Response.Redirect from an ASP page to another one (I wrote, with nothing special) - I can absolutely, positively gaurantee referer will be filled in.
I just created to classic asp pages...
page1.asp:
<% response.Redirect "page2.asp" %>
page2.asp:
<% response.Write Request.ServerVariables("HTTP_REFERER") %>
Page2 outputs nothing when opened from redirect like this. It does display
page if gotten to from a hyperlink.
Like John said, you should get back to basics. Try this test yourself and
see what happens. I've never worked with classic asp much, so maybe I did
something wrong...
PS: Request.UrlReferrer maybe a simpler way to get
Request.ServerVariables("HTTP_REFERER")
Greg
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... This works with ASP to ASP, but not ASP to ASP.NET and to be clear, if you Response.Redirect from an ASP page to another one (I wrote, with nothing special) - I can absolutely, positively gaurantee referer will be filled in.
I just created to classic asp pages...
page1.asp:
<% response.Redirect "page2.asp" %>
page2.asp:
<% response.Write Request.ServerVariables("HTTP_REFERER") %>
Page2 outputs nothing when opened from redirect like this. It does display page if gotten to from a hyperlink.
Like John said, you should get back to basics. Try this test yourself and see what happens. I've never worked with classic asp much, so maybe I did something wrong...
Drebin,
You're not getting it. Get down to the basic question: "is the Referrer
header being sent to your ASP.NET application?" Forget about
Request.ServerVariables("HTTP_REFERER") . All that does is show what's in
the header. The header is what you should be looking at.
If you see that the header is being sent to ASP.NET, yet
Request.ServerVariables("HTTP_REFERER") is blank, THEN you should worry
about ASP.NET doing something different.
And, BTW, a lot of people use Request.ServerVariables("HTTP_REFERER") in
ASP.NET, and it works. ASP.NET has been out for about three years - this
would have been fixed by now if it didn't work for anyone at all.
In other words, "yes, it's just you".
--
John Saunders
Turn on tracing for the page and look at the trace information to see if the
referrer is in the headers?
<%Page Language="whatever" Trace="True" %>
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:OE*************@TK2MSFTNGP09.phx.gbl... "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... This works with ASP to ASP, but not ASP to ASP.NET and to be clear, if you Response.Redirect from an ASP page to another one (I wrote, with nothing special) - I can absolutely, positively gaurantee referer will
be filled in.
I just created to classic asp pages...
page1.asp:
<% response.Redirect "page2.asp" %>
page2.asp:
<% response.Write Request.ServerVariables("HTTP_REFERER") %>
Page2 outputs nothing when opened from redirect like this. It does display page if gotten to from a hyperlink.
Like John said, you should get back to basics. Try this test yourself
and see what happens. I've never worked with classic asp much, so maybe I
did something wrong...
Drebin,
You're not getting it. Get down to the basic question: "is the Referrer header being sent to your ASP.NET application?" Forget about Request.ServerVariables("HTTP_REFERER") . All that does is show what's in the header. The header is what you should be looking at.
If you see that the header is being sent to ASP.NET, yet Request.ServerVariables("HTTP_REFERER") is blank, THEN you should worry about ASP.NET doing something different.
And, BTW, a lot of people use Request.ServerVariables("HTTP_REFERER") in ASP.NET, and it works. ASP.NET has been out for about three years - this would have been fixed by now if it didn't work for anyone at all.
In other words, "yes, it's just you". -- John Saunders
Drebin,
Any luck with this?
John Saunders
Could you use something like
Response.ContentType = "application/vnd.ms-excel"
eg: Response.Referrer = "targetpage.aspx"
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: alex p |
last post by:
I have create a website that links to other websites, using a
response.redirect("URL_OF_WEBSITE")
For some reason I have managed to get on top at Google, with these pages
that only redirect to a...
|
by: Drebin |
last post by:
I posted this over at the ASP.NET group, but you guys are pretty sharp - is
this an obvious answer for anyone?? I'm really jammed up!!
---------------------------------------
I am retrofitting...
|
by: Adrian Parker |
last post by:
When using Response.Redirect(var) in my code, the browser just shows a
blank page. It works fine on the development machine (winxp) but not on a
server machine (win2k). If I view the code on...
|
by: Tim |
last post by:
Hello,
Is there a way to "cancel" a response.Redirect? For example, in the code
below, could I insert anything in the Catch statement that would cancel the
redirect and resume flow after the...
|
by: batista |
last post by:
Hello All,
I want to know the Difference Between
Server.Transfer() And Response.Redirect()?
|
by: Sridhar |
last post by:
Hi,
I have a form where I have several text boxes. I am filling all those
values and when I click on submit I am redirecting to new webform using
Response.Redirect(). In the new webform if I...
|
by: Dornel |
last post by:
Hi all,
My session variables are lost when I using response.redirect at first time...
In the second time, the problem not exists.
example in page 1(create session and redirect):
...
|
by: Rhiannone |
last post by:
Can you use relative addressing when using response.redirect; i.e something that would look like this
<% if session("superuser") <> true then response.redirect "../../../edit/logout.asp" %>
or...
|
by: Jeff User |
last post by:
Hi all
What are the ramifications of either of the possible values for the
boolean endResponse parameter when calling
Response.Redirect?
If if false, is there some mysterious processing that...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |