467,869 Members | 1,409 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,869 developers. It's quick & easy.

Creating a Web Proxy

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?
Nov 19 '05 #1
  • viewed: 1804
Share:
2 Replies
Chamander2kool wrote:
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,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #2
most likely the hosts proxy only allows local access from the server for
your account.

-- bruce (sqlwork.com)
"Chamander2kool" <vz******@verizon.net> wrote in message
news:JdvOd.16108$uc.15834@trnddc08...
| 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?
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by William Ryan | last post: by
19 posts views Thread by Steve | last post: by
1 post views Thread by Jeevan | last post: by
16 posts views Thread by tshad | last post: by
6 posts views Thread by | last post: by
reply views Thread by =?Utf-8?B?UlN1Yg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.