Creating a Web Proxy

  • Thread starter Thread starter Chamander2kool
  • Start date Start date
C

Chamander2kool

I use Godday.com for hosting.
What I'm trying to do is create a web proxy.
This is the code I have currently:




<%@ 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()
wc.Credentials = System.Net.CredentialCache.DefaultCredentials
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, aslong as the search pages are on godaddy's server...it works fine.
As soon as you request something like www.microsoft.com or yahoo.com, it
returns a error

The error returned is
Exception Details: System.Net.WebException: The remote server returned
an error: (401) Unauthorized.

Source Error:


Line 18: wc = new WebClient()
Line 19: wc.Credentials = System.Net.CredentialCache.DefaultCredentials
Line 20: st = wc.OpenRead(u)
Line 21: sr = new StreamReader(st)
Line 22: 'Response.Write(sr.ReadToEnd())


Does anyone know what I'm doing wrong and how to fix this problem?
 
Chamander2kool said:
I use Godday.com for hosting.
What I'm trying to do is create a web proxy.
This is the code I have currently:




<%@ 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()
wc.Credentials = System.Net.CredentialCache.DefaultCredentials
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, aslong as the search pages are on godaddy's server...it works
fine. As soon as you request something like www.microsoft.com or
yahoo.com, it returns a error

The error returned is
Exception Details: System.Net.WebException: The remote server
returned an error: (401) Unauthorized.

Source Error:


Line 18: wc = new WebClient()
Line 19: wc.Credentials =
System.Net.CredentialCache.DefaultCredentials Line 20: st =
wc.OpenRead(u) Line 21: sr = new StreamReader(st)
Line 22: 'Response.Write(sr.ReadToEnd())


Does anyone know what I'm doing wrong and how to fix this problem?

You're using your ASP.NET account's credentials. Is that really what
you want?

Cheers,
 
most likely the hosts proxy only allows local access from the server for
your account.

-- bruce (sqlwork.com)


| I use Godday.com for hosting.
| What I'm trying to do is create a web proxy.
| This is the code I have currently:
|
|
|
|
| <%@ 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()
| wc.Credentials = System.Net.CredentialCache.DefaultCredentials
| 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, aslong as the search pages are on godaddy's server...it works fine.
| As soon as you request something like www.microsoft.com or yahoo.com, it
| returns a error
|
| The error returned is
| Exception Details: System.Net.WebException: The remote server returned
| an error: (401) Unauthorized.
|
| Source Error:
|
|
| Line 18: wc = new WebClient()
| Line 19: wc.Credentials = System.Net.CredentialCache.DefaultCredentials
| Line 20: st = wc.OpenRead(u)
| Line 21: sr = new StreamReader(st)
| Line 22: 'Response.Write(sr.ReadToEnd())
|
|
| Does anyone know what I'm doing wrong and how to fix this problem?
 
Back
Top