Click here to Skip to main content
14,271,759 members
   

C#

 
GeneralRe: New version of visual studio Pin
Brian_TheLion14-Aug-19 17:55
memberBrian_TheLion14-Aug-19 17:55 
GeneralRe: New version of visual studio Pin
Benktesh Sharma15-Aug-19 2:09
memberBenktesh Sharma15-Aug-19 2:09 
QuestionC# Get IP Address of Primary NIC - A Question Pin
Kevin Marois7-Aug-19 7:28
professionalKevin Marois7-Aug-19 7:28 
AnswerRe: C# Get IP Address of Primary NIC - A Question Pin
Dave Kreskowiak7-Aug-19 7:31
mveDave Kreskowiak7-Aug-19 7:31 
GeneralRe: C# Get IP Address of Primary NIC - A Question Pin
Kevin Marois7-Aug-19 7:50
professionalKevin Marois7-Aug-19 7:50 
GeneralRe: C# Get IP Address of Primary NIC - A Question Pin
Dave Kreskowiak7-Aug-19 9:41
mveDave Kreskowiak7-Aug-19 9:41 
AnswerRe: C# Get IP Address of Primary NIC - A Question Pin
Randor 9-Aug-19 15:26
professional Randor 9-Aug-19 15:26 
Questionrequest.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 11:53
member_Q12_5-Aug-19 11:53 
I used various code combinations for web page reading, but i have this error:
[The remote server returned an error: (403) Forbidden]

My questions:
- I use VS2010. It's because my version of VS is so old, i keep getting this error?
- Is the same problem for newer versions of VS?
- If newer versions have no problem, what can i add to my version?
- Or if it's the code problem, what is the correct code?
This problem appear for SOME websites. But not on all.

this is a sample of code i use:
string urlAddress = "http://somesite.com";
string ReadPage()
{
    string page = "";
    HttpWebRequest request;
    HttpWebResponse response = null;
    Stream stream = null;
    request = (HttpWebRequest)WebRequest.Create(urlAddress);
    request.UserAgent = "Foo";
    request.Accept = "*/*";
    response = (HttpWebResponse)request.GetResponse();
    stream = response.GetResponseStream();

    StreamReader sr = new StreamReader(stream, System.Text.Encoding.Default);
    page = sr.ReadToEnd();
    if (stream != null) stream.Close();
    if (response != null) response.Close();
    //-------------------------------------------------------------
    return page;
}

Thank you.
AnswerRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 12:04
mveDave Kreskowiak5-Aug-19 12:04 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 12:21
member_Q12_5-Aug-19 12:21 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Eddy Vluggen5-Aug-19 12:35
mveEddy Vluggen5-Aug-19 12:35 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 12:48
member_Q12_5-Aug-19 12:48 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 13:37
mveDave Kreskowiak5-Aug-19 13:37 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 13:01
member_Q12_5-Aug-19 13:01 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 13:38
mveDave Kreskowiak5-Aug-19 13:38 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 13:31
mveDave Kreskowiak5-Aug-19 13:31 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 14:21
member_Q12_5-Aug-19 14:21 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 15:30
mveDave Kreskowiak5-Aug-19 15:30 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 14:40
member_Q12_5-Aug-19 14:40 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 15:29
mveDave Kreskowiak5-Aug-19 15:29 
AnswerRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Luc Pattyn5-Aug-19 13:16
professionalLuc Pattyn5-Aug-19 13:16 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 13:56
member_Q12_5-Aug-19 13:56 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Luc Pattyn5-Aug-19 14:02
professionalLuc Pattyn5-Aug-19 14:02 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
_Q12_5-Aug-19 14:05
member_Q12_5-Aug-19 14:05 
GeneralRe: request.GetResponse() - The remote server returned an error: (403) Forbidden Pin
Dave Kreskowiak5-Aug-19 15:32
mveDave Kreskowiak5-Aug-19 15:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.