Asked by:
HTTP/1.1 500 Internal Server Error when making a WebRequest at a proxy links?

Question
-
User-1485098150 posted
I have a Json that contains an array of objects,every object having a link that is accessing an mp4 movie on a server.For some of this links,when I make a webrequest,I receive a 500 Internal Server Error.
I used Fiddler in order to debug the code and I have seen that all the links that contains proxy in the Host name throw this kind of error,while the other link that contains static in Host name do not throw this error.Also,I can access the proxy links in the browser,but I receive an error in the webrequest.
This is what I receive in Fiddler in case of static links:
HTTP/1.1 200 OK Server: Apache/2.2.15 (CentOS) X-Forwarded-For: 95.101.2.212 Content-Type: video/mp4 Accept-Ranges: bytes ETag: "fdda6-d897b6-4ce4f78025680" Last-Modified: Mon, 12 Nov 2012 17:16:58 GMT Content-Length: 14194614 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET,OPTIONS Cache-Control: public, max-age=603910 Date: Sat, 10 Aug 2019 07:33:43 GMT Connection: keep-alive Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET,OPTIONS
This is what I receive in the case of proxy links:
HTTP/1.1 500 Internal Server Error X-Forwarded-For: 95.101.2.97 Content-Type: application/json;charset=utf-8 Access-Control-Allow-Origin: * Date: Sat, 10 Aug 2019 07:33:43 GMT Connection: close
This is a screenshot from Fiddler that shows one link that worked and another that receive an error:https://i.imgur.com/GaZDDSk.png . This is the part of the code where I make a request where url is the link that i try to access:
WebRequest request = WebRequest.Create(new Uri(vd.url)); using (WebResponse response = request.GetResponse()) { Console.WriteLine("{0} {1} {2}",e, response.ContentLength, response.ContentType); }
What can I do in order to access those proxy links using a web request?I also realised that the link is making a redirect.In Transport header of the response is a link that the browser access.How can I access the redirect link from the Transport Header in webrequest ?
I just realise that the link is making a redirect.In Transport header of the response is a link that the browser access.How can I access the redirect link from the transport Header in webrequest ? This is what I receive in Fiddler when I'm accessing the proxy link in the Browser:https://imgur.com/gallery/JDNvVbO This is what I receive in Fiddler after the browser make a redirect in the link from the Transport header : https://imgur.com/gallery/BdfYh0h The link in the transport header does nor appear when I try to access the link from my application.Sunday, August 11, 2019 5:08 AM
All replies
-
User475983607 posted
I'm guessing "proxy" is code that you wrote and the "proxy" is returning a 301 redirect. Set the AllowAutoRedirect to true.
https://stackoverflow.com/questions/2033541/handling-redirection-in-net-webrequest
Otherwise, read the location header in the response and do another HTTP GET.
Sunday, August 11, 2019 11:45 AM -
User-1485098150 posted
I tried auto redirect.I still get this error when i'm making a request to a proxy link: The remote server returned an error: (500) Internal Server Error.
Sunday, August 11, 2019 12:52 PM -
User475983607 posted
A 500 is commonly due to an incorrect HTTP request parameters of a problem with the code running on the server. We cannot see the server code so there is not much we do.Sunday, August 11, 2019 9:19 PM