views:

80

answers:

2

Hi,

Anyone have an idea offhand regarding why a link with an "@" in it works on my browser, but when I go to get this particular link in my HttpWebRequest code I get a 405 error?

The remote server returned an error: (405) Method Not Allowed.

The example link in question:

http://internal_link/@api/deki/site/logo.png

thanks

+3  A: 

An http is an http request. The server doesn't care whether it's from a browser or something else. If it rejects one and not the other, it's because you're not sending the same request. Some things to check might be the user agent, cookies, or whether the browser is somehow altering the @ sign in that url before sending it. You can use a program like fiddler to check the request sent by the browser and alter your code to make sure it sends the same request.

Joel Coehoorn
ummm..just run through fiddler...in the Inspectors / Raw section the "GET url..." line still shows the "@" in the same state (not escaped). There are come cookies there but all the other resources from the page are coming back find, just not this one with the "@" in it. I wonder if Fiddler is doing some translation under the bonnet itself?
Greg
+4  A: 

The @ sign is a reserved character in a URL.

reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
              "$" | ","

(See http://www.ietf.org/rfc/rfc2396.txt)

So I'd suggest to escape (something the browser does automatically), using %40 instead of @.

Pindatjuh
This is my thought exactly
Sky Sanders
oh..are you seeing that the browser would do this behind the scenes?
Greg
@Greg: they should. It's a requirement in the URL specifications.If HTTP server coders and HTTP browser coders follow the specs, they can work together.The URL you type in your browser will be translated to a "well-formed" URL, since this will follow the specs while your entered URL may not.
Pindatjuh