C# Proxy The Remote Server Returned An Error 403 Forbidden
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About
The Remote Server Returned An Error 403 Forbidden Web Deploy
Us Learn more about Stack Overflow the company Business Learn more about hiring developers the remote server returned an error 403 forbidden c# webclient or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
The Remote Server Returned An Error 403 Forbidden Webrequest
Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting Error “The remote server returned an the remote server returned an error 403 forbidden sharepoint 2010 error: (403) Forbidden” when screen scraping using HttpWebRequest.GetResponse() up vote 7 down vote favorite 3 We have a tool which checks if a given URL is a live URL. If a given url is live another part of our software can screen scrap the content from it. This is my code for checking if a url is live public static bool IsLiveUrl(string url) { HttpWebRequest webRequest the remote server returned an error (407) proxy authentication required. c# = WebRequest.Create(url) as HttpWebRequest; webRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5"; webRequest.CookieContainer = new CookieContainer(); WebResponse webResponse; try { webResponse = webRequest.GetResponse(); } catch (WebException e) { return false; } catch (Exception ex) { return false; } return true; } This code works perfectly but for a particular site hosted on apache i am getting a web exception with following message. "The remote server returned an error: (403) Forbidden" On further inspection i found the following details in the WebException object Status="ProtocolError" StatusDescription="Bad Behaviour" This is the request header "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5 Host: scenicspares.co.uk Connection: Keep-Alive" This is the response header "Keep-Alive: timeout=4, max=512 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html Date: Thu, 13 Jan 2011 10:29:36 GMT Server: Apache" I extracted these headers using a watch in vs2008. The frame work in use is 3.5. c# httpwebrequest screen-scraping httpwebresponse http-status-code-403 share|improve this question edited Jan 13 '11 at 13:50 asked Jan 13 '11 at 10:35 Syed Salman Akbar 4142516 add a comment| 2 Answers 2 active oldest votes up vote 13 down vote It turned out that all i needed to do was following webReque
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
The Remote Server Returned An Error (407) Proxy Authentication Required. C# Web Client
About Us Learn more about Stack Overflow the company Business Learn more about the remote server returned an error (403) forbidden. httpwebrequest c# hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
System.net.webexception: The Remote Server Returned An Error: (403) Forbidden.
the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up WebRequest Proxy - 403 http://stackoverflow.com/questions/4679085/getting-error-the-remote-server-returned-an-error-403-forbidden-when-screen forbidden Error up vote 0 down vote favorite I want to connect URL via proxy server but when I am using proxy and try to get response it returns (403) Forbidden . Without proxy everything works . private void button1_Click(object sender, EventArgs e) { CookieContainer cookies = new CookieContainer(); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://wikipedia.com"); webRequest.Proxy = new WebProxy("41.217.193.6", 80); webRequest.CookieContainer = cookies; webRequest.Accept = "*/*"; webRequest.Timeout http://stackoverflow.com/questions/9645304/webrequest-proxy-403-forbidden-error = 9000; HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); /// <== The remote server returned an error: (403) Forbidden. StreamReader responseReader = new StreamReader(response.GetResponseStream()); string sResponseHTML = responseReader.ReadToEnd(); Clipboard.SetText(sResponseHTML); } c# .net proxy webrequest share|improve this question edited Mar 10 '12 at 9:22 Peter O. 16.1k74861 asked Mar 10 '12 at 9:20 piterskyy 2015 1 did you set the credentials for the request? –Chamika Sandamal Mar 10 '12 at 9:26 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted I think the proxy ("41.217.193.6", 80) needs authentication. If you try a new proxy, the code above works. For example, at the time of writing, the following proxy works. webRequest.Proxy = new WebProxy("200.61.168.141", 8080); share|improve this answer answered Mar 10 '12 at 12:35 Jiaji Wu 37129 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ef0f1c39-fc92-4cde-9920-597a8d6981f9/403-error-the-remote-server-returned-an-error-403-forbidden?forum=sqlreportingservices Remove From My Forums Answered by: 403 error: The remote server returned an error: (403) Forbidden. SQL Server > SQL Server Reporting Services, Power View Question 0 Sign in to vote When I try to view the report, I got the error "The remote server the remote returned an error: (403) Forbidden. ". And in the event log , I got the detaiil excception: Event Type: WarningEvent Source: ASP.NET 2.0.50727.0Event Category: Web Event Event ID: 1309Date: 2007-7-16Time: 11:28:29User: N/AComputer: WEIGUANGDescription:Event code: 3005 Event message: An unhandled exception has occurred. Event time: 2007-7-16 the remote server 11:28:29 Event time (UTC): 2007-7-16 3:28:29 Event ID: 3c4daa414c89430786c106f3c9085b56 Event sequence: 10 Event occurrence: 1 Event detail code: 0 Application information: Application domain: /LM/W3SVC/1/Root/Reports-2-128290300818412520 Trust level: RosettaMgr Application Virtual Path: /Reports Application Path: C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\ Machine name: WEIGUANG Process information: Process ID: 4152 Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE Exception information: Exception type: WebException Exception message: The remote server returned an error: (403) Forbidden. Request information: Request URL: http://localhost/Reports/Reserved.ReportViewerWebControl.axd?OpType=StyleSheet&Version=2005.090.3042.00 Request path: /Reports/Reserved.ReportViewerWebControl.axd User host address: 127.0.0.1 User: ASIAPACIFIC\liweig Is authenticated: True Authentication Type: NTLM Thread account name: NT AUTHORITY\NETWORK SERVICE Thread information: Thread ID: 5 Thread account name: NT AUTHORITY\NETWORK SERVICE Is impersonating: True Stack trace: at Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boole