471,337 Members | 879 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Strange Behavior in WebRequest.Create("...") and System.Uri("...")

Hi.

I've noticed, after moving some of our code to 2.0, that
System.Net.WebRequest.Create(System.String) and
System.Uri(System.String) no longer behave as they did in 1.1
framework.

Example:

string emailHttpPath =
"http://myexchange.mydomain.com/exchange/mymailboxalias/inbox/mysubfolder./;

// Notice the punctutation in the end, which is a legal web folder
name.

HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(emailHttpPath);

// Do stuff with the webrequest...

// This fails with a 404 error in 2.0 framework, but succeeds in 1.1
framework
HttpWebResponse webResponse =
(HttpWebResponse)webRequest.GetResponse();

The reason the above code fails, is that when
WebRequest.Create(System.String) is called, it removes the punctuation
from the httpPath making it look like this:
http://myexchange.mydomain.com/excha...x/mysubfolder/
WITHOUT the punctuation.
The url without the trailing punctuation correctly doesn't exist, so
the error it self is perfectly correct. However, I can't see how the
parsing of the url can be correct.

The same thing also applies for the System.Uri class. I tried
instantiating a System.Uri object with the above string http path, and
it also removes the trailing punctuation. I'm guessing
WebRequest.Create(System.String) internally puts a System.Uri on top of
the string http path.

What to do here?
I found this information about changes in System.Uri:
http://msdn.microsoft.com/netframewo...ce.aspx#System

Which seems to suggest that System.Uri always escapes urls. In the
above case, it seems however, that it doesn't escape correctly.

Dec 15 '05 #1
0 1647

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by William Wisnieski | last post: by
11 posts views Thread by Robert Lacoste | last post: by
5 posts views Thread by msigwald | last post: by
8 posts views Thread by Henrik | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.