hankknight
asked on
ASP.NET/VB: Username and password with WebClient()/DownloadString
How can I avoid this error?
The remote server returned an error: (401) Unauthorized.
The username is "userx" and the password is "passwordx".
<%@ Page Language="VB"%>
<%@Import namespace="System"%>
<%@Import namespace="System.Web"%>
<%@Import namespace="System.Net"%>
<%@Import namespace="System.IO"%>
<%@Import namespace="System.Text"%>
<%
Dim data As String
Using WC As New System.Net.WebClient()
data = WC.DownloadString("https://example.com.com/")
End Using
HttpContext.Current.Respon se.Write(d ata)
%>
The remote server returned an error: (401) Unauthorized.
The username is "userx" and the password is "passwordx".
<%@ Page Language="VB"%>
<%@Import namespace="System"%>
<%@Import namespace="System.Web"%>
<%@Import namespace="System.Net"%>
<%@Import namespace="System.IO"%>
<%@Import namespace="System.Text"%>
<%
Dim data As String
Using WC As New System.Net.WebClient()
data = WC.DownloadString("https://example.com.com/")
End Using
HttpContext.Current.Respon
%>
ASKER
Using ASP.NET I want to grab the contents of this page:
http://www.pagetutor.com/keeper/mystash/secretstuff.html
Username: jimmy
Password: page
This does not work:
http://www.pagetutor.com/keeper/mystash/secretstuff.html
Username: jimmy
Password: page
This does not work:
<%@ Page Language="VB"%>
<%@Import namespace="System"%>
<%@Import namespace="System.Web"%>
<%@Import namespace="System.Net"%>
<%@Import namespace="System.IO"%>
<%@Import namespace="System.Text"%>
<%
Dim data As String
Using WC As New System.Net.WebClient()
' Username: jimmy
' Password: page
data = WC.DownloadString("http://www.pagetutor.com/keeper/mystash/secretstuff.html")
End Using
HttpContext.Current.Response.Write(data)
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The possible reason could be that your default web.config (the system one) is configured to check authenticity of users.
Or you had set some settings in IIS that is restricting you from accessing web page directly without authentication. I am not getting that setting name in my mind.