473,466 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with Uri.MakeRelative() method

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
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
0 994

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
4
by: Steve - DND | last post by:
We're currently working on a project with v1.0 of the .Net Framework, and are experiencing some issues with System.Uri. We have two Uri objects: Uri uriBase = new...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
0
by: Nathan Sokalski | last post by:
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...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
10
by: Markus Svilans | last post by:
Hi, I have a weird problem in a virtual method. The original method code raises an access violation when it is run. The solution to the problem is to declare a dummy integer inside the virtual...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.