Strange Behavior in WebRequest.Create("...") and System.Uri(
Exchange Server Forum Index Exchange Server
Discussion forums for Microsoft Exchange Server users.
Microsoft Outlook
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ExchangeServerHelp.com
Strange Behavior in WebRequest.Create("...") and System.Uri(

 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development
Author Message
Guest






Posted: Thu Dec 15, 2005 9:58 am    Post subject: Strange Behavior in WebRequest.Create("...") and System.Uri( Reply with quote

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/mysubfol...



// 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/exchange/mymailboxalias/inbox/mysubfol...

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/netframework/programming/obsoleteapi/ObsByN...



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

Back to top
 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server Dedicated Servers
New Topics Powered by phpBB