PDA

View Full Version : Proxy


BrockLesnar
02-09-2005, 09:59 PM
I'm trying to create a web proxy. Here is my code


<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Page Language="VB" Debug="true" %>
<script language="VB" runat="server">
Dim u
Dim wc as WebClient
Dim st as Stream
Dim sr as StreamReader
sub page_load
U = Request("u")
if U = "" then
U = "http://www.quiddity128.net"
end if

wc = new WebClient()
st = wc.OpenRead(u)
sr = new StreamReader(st)
'Response.Write(sr.ReadToEnd())
myPage.Text = sr.ReadToEnd()
st.Close()
end sub
</script>

<form runat="server">
<input type=text size=50 name="u">
<input type=submit>
</form>

<asp:literal id="myPage" runat="server"/>


Now, it works fine aslong as the page requested is in the server itself BUT if I request something like microsoft.com or yahoo.com it returns a error called

"Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized."
What am i doing wrong?

miranda
02-10-2005, 09:06 AM
I am curious does this happen on small sites too? The 401 error tells me maybe it is the big sites trying to protect some resources by denying this.