Creating a Web Proxy

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?
 
J

Joerg Jooss

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,
 
B

bruce barker

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top