This project has moved. For the latest updates, please go here.

The remote server returned an error: (403) Forbidden

Jul 1, 2010 at 11:38 AM
Edited Jul 1, 2010 at 11:41 AM

i want to get HTML output in

but i always get

HTTPWEBRESPONSE The remote server returned an error: (403) Forbidden

I am using HttpWebResponse

protected string GetHtmlStringA(string url)
        string sHtml = "";
        HttpWebRequest request;
        HttpWebResponse response = null;
        Stream stream = null;
        request = (HttpWebRequest)WebRequest.Create(url);
        response = (HttpWebResponse)request.GetResponse();
        stream = response.GetResponseStream();
        StreamReader sr = new StreamReader(stream, System.Text.Encoding.Default);
        sHtml = sr.ReadToEnd();
        if (stream != null) stream.Close();
        if (response != null) response.Close();
        return sHtml;

i also try with UserAgent but it is the same

req.request=  "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/2009073022 Firefox/3.0.13";

I also try with HTMLDocument in HTML agility pack but is the same. Any idea why. From browser page is normally visible...

i can't find any solution on forums or internet