Library code snippets
Spoofing the Referrer using HttpWebRequest
By Dave Wanta, published on 20 Feb 2005
I noticed the article the other day on your website about "Spoofing the Referer During a Web Request" Immediately after reading it I was wondering if you can do this using ASP.NET, the answer is a resounding "YES, of course!". This works because the http standards allow the client to actually dictate the HTTP_Referer variable.
Here is the code:
Function FetchURL(SomeURL as String, Referer As String) as String
Dim WebResp as HTTPWebResponse
Dim HTTPGetRequest as HttpWebRequest
Dim sr As StreamReader
dim myString as String
HTTPGetRequest = DirectCast(WebRequest.Create(SomeURL),HttpWebRequest)
HTTPGetRequest.KeepAlive = false
HTTPGetRequest.Referer = Referer
WebResp = HTTPGetRequest.GetResponse()
sr = new StreamReader(WebResp.GetResponseStream(), Encoding.ASCII)
myString = sr.ReadToEnd()
Return myString
End Function
You can then call this using the following:
Dim PageString As String
PageString = FetchURL("http://www.google.com/","http://www.microsoft.com")
Related articles
Related discussion
-
Why choose c# when there is Java
by Thaj06 (0 replies)
-
Change color while typing in rich text box
by Akhtar Hussain (0 replies)
-
Third party components to enhance User Interface of Windows based application
by Shaila14041981 (0 replies)
-
VB.NET DataGridView Sort
by bradhen (0 replies)
-
About Comparison in Asp.Net
by S_Rahul (0 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
I love this article (post). This is exactly what I am looking to do, but my entire site is written in classic .asp. Is there a way to do this in classic ASP?
I would not be opposed to a link from my .asp that goes to an ASP.NET page that would include the script you created and automatically redirect the user to the page specified in the link. Kind of a middle processing ground.
Does this make sense? If so can anyone help make it happen?? Please let me know your thoughts and abilities on helping me.
Thank you,
Jerry
its not a mistake
1 is the referrer other one is the site to visit...
and the function accepts 2 parameters.....
This is a very short and sweet - though activex - method - short enough to fit in a bookmarklet (IE only obviously)
http://sportsforum.ws/spoof.html
Oh dear!
I've corrected those now.
This thread is for discussions of Spoofing the Referrer using HttpWebRequest.