views:

577

answers:

3

Okay so here's what I'm doing. I'm making a request to a server to pull down a file. I do this by making a WebRequest to the website the getting the response just as you usually would, although i get a 403 error saying i don't have permissions.

Problem is when i plug the URL into Google Chrome I get redirected and the file i requested comes down. I've tried the URL on other browsers and get the 403 error.

What is Google Chrome doing that allows it to bypass the 403 error? I've tried using the Google Chrome User Agent, but that doesn't help me.

Help

A: 

Possibly the web server recognizes the Chrome user agent and allows the file to be downloaded by it, but not by other user agents. Set up your WebRequest to use the same user agent strings and settings as Google Chrome - by default it might be using the IE settings.

Edit: Here's instruction from MSDN about how to set the WebRequest user agent string. To find out the user agent of any browser, enter this into its address bar:

javascript:prompt('my user agent string is', navigator.userAgent);
John K
A: 

The 403 status code indicates the resource you're attempting to reach is Forbidden. As in, don't ask because you're not getting it. This differs from the 401 code in that an Authorization challenge is presented before the server will confirm delivery of the resource.

While this could be programmatic configuration, this might also be explained by access restrictions on the resource as configured through the web server.

Can you verify that the downloaded resource in Google Chrome is the expected resource you're attempting to reach?

jro
A: 

Thanks for the help. None of your answers helped me directly, but thanks for trying.

My Program was trying to pull a file off a server. I had figured out how to get around the authentication issues and finding the file on the server while using Chrome. It turns out that their web service is more advanced using user sessions.

Basically I didn't have access to the webservice commands, so all i could do is use the basic http urls to get a predefined response. The files url that i used to get the file of the server was not unique, it was dynamic depending on the webbrowser / the session. I was using the HTTPRequest object to get the HTML file so i could parse it. With the html file i parsed it to find out the dynamic ID of the file (I thought it was unique). Then I'd attach that to the end of a URL. In Chrome I would be redirected and presented with the download prompt. Problem was that I needed the webbrowser object when i wanted to pull down the file. Knowing this i used the webbrowser object to get the file ID, then used the same webbrowser object (Technically same sessions according the webserver) to pull down the file.

It's rather complicated. Basically my program is a little hack that provides functionality that the server is try block.

Hope this assisted you guys in any of your future projects.

Thomas
"It's rather complicated" will definitely help me if I need to implement a similar solution. Thanks! :)
mrduclaw
Yeah it's all about the cookies. This is my first program using the internet, probably should've chosen a little easier program to get started with.
Thomas