Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with Uri.MakeRelative() method

Reply
Thread Tools

Problem with Uri.MakeRelative() method

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      05-29-2005
When using the MakeRelative() method of the Uri class, I have noticed that
the Query and Fragment are never returned. I ran the following code and
recieved the following results:

Dim initialUri1 As New Uri("http://www.mydomain.com/index.aspx")

Dim initialUri2 As New Uri("http://www.mydomain.com/dir1/index.aspx")

Dim initialUri3 As New Uri("http://www.mydomain.com/dir1/dir2/index.aspx")

Dim fragmentUri As New Uri("http://www.mydomain.com/dir1/index.aspx#QUOTES")

Dim queryUri As New
Uri("http://www.mydomain.com/dir1/index.aspx?qname=myself")

Response.Write("Result for fragmentUri: " &
initialUri1.MakeRelative(fragmentUri) & "<br>")

Response.Write("Result for queryUri: " & initialUri1.MakeRelative(queryUri)
& "<br>")

Response.Write("Result for fragmentUri: " &
initialUri2.MakeRelative(fragmentUri) & "<br>")

Response.Write("Result for queryUri: " & initialUri2.MakeRelative(queryUri)
& "<br>")

Response.Write("Result for fragmentUri: " &
initialUri3.MakeRelative(fragmentUri) & "<br>")

Response.Write("Result for queryUri: " & initialUri3.MakeRelative(queryUri))


This gave me the following results:

Result for fragmentUri: dir1/index.aspx
Result for queryUri: dir1/index.aspx
Result for fragmentUri:
Result for queryUri:
Result for fragmentUri: ../index.aspx
Result for queryUri: ../index.aspx

As you can see, the correct path is always returned but the Query and
Fragment properties are completely ignored. Is there a way to return the
Query or Fragment without manually adding it?
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
algorithm for Modified Distribution Method / Transportation Simplex Method/Transport Problem deep.goyal@tcs.com C++ 1 01-12-2005 02:27 AM
algorithm for Modified Distribution Method / Transportation Simplex Method/Transport Problem Deepak C Programming 1 01-11-2005 07:18 AM
Problem: return from one method when another method is called Magne Bergfjord Java 1 04-20-2004 04:25 PM
Problem posting a method as an argument to an method.. =?ISO-8859-1?Q?Christian_M=F6rck?= C++ 4 11-21-2003 07:38 AM



Advertisments