473,806 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URl rewrite and relative paths

Sorry to post this again - I didn't use my MSDN alias previously...

I'm using a url rewriting mechanism to make my site's urls more
search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx
which is actually internally mapped to
http://www.mysite.com/links.aspx?link=1023. This works fine and makes the
site look a lot cleaner.

The problem I'm having is with controls on the target page. I render all the
urls as root relative so that I'm independent of whether I'm a root web or
an application, so we have ~/images/img1.jpg for images and and
~/links/4096.aspx as a child link of 1023 for example.

The problem is that the ASP.NET controls convert my relative paths to
images/img1.jpg and links/4096.aspx, when evaluated these become
http://www.mysite.com/links/images/img1.jpg and
http://www.mysite.com/links/links/4096.aspx which of course don't exist.

Now interestingly, if I call ResolveUrl in the page on say ~/images/img1.jpg
I correctly get /images/img1.jpg. There's basically a different behaviour
between ResolveUrl and Control.Resolve Url.

I have a workaround, which is to make everything an absolute path, but it's
not very satisfactory since it makes demoing stuff to clients a pain - you
have to have a root web available rather than just creating an application
directory somewhere.

I'd call this a bug, since there should only be one implementation of
something like ResolveUrl.

Anyone else found this and have a better workaround?

Paul

Nov 19 '05 #1
9 1811
Hi Paul,

Welcome to ASPNET newsgroup.
As for the problem you mentioned, I've also reproduced it on my side. Seems
there is something wrong with the Control when Render the certain Html Tag.
I'll consult some other experts on this to see whehter this issue is
already addressed and will let you know as soon as I get any update.

Thank you for your understanding.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 19 '05 #2

"Paul Hatcher" <pa**********@o nline.nospam> wrote in message
news:ef******** ******@tk2msftn gp13.phx.gbl...
Sorry to post this again - I didn't use my MSDN alias previously...

I'm using a url rewriting mechanism to make my site's urls more
search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx which is actually internally mapped to
http://www.mysite.com/links.aspx?link=1023. This works fine and makes the
site look a lot cleaner.

Instead of using http://www.mysite.com/links/1023.apx could you use
something like http://www.mysite.com/1023.apx (or even better is
http://www.mysite.com/link-1023.aspx b/c it be easier to detect and more SEO
friendly) and have that rewrite to
http://www.mysite.com/links.aspx?link=1023. Just a thought.

Mike
Nov 19 '05 #3
> Welcome to ASPNET newsgroup.
I've been around since Beta2 of .NET 1.0, but been a bit quiet :-)

Thanks for the response.

Paul

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:JR******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Paul,

Welcome to ASPNET newsgroup.
As for the problem you mentioned, I've also reproduced it on my side.
Seems
there is something wrong with the Control when Render the certain Html
Tag.
I'll consult some other experts on this to see whehter this issue is
already addressed and will let you know as soon as I get any update.

Thank you for your understanding.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #4
Mike

Thanks - why is http://www.mysite.com/link-1023.aspx more SEO friendly than
http://www.mysite.com/links/1023.aspx, is it because the page name is not
all numeric?

I also thought of http://www.mysite.com/1023/link.aspx which is quite nice
naming

Paul

"vMike" <Mi************ @spamnotgewarre n.com.delete> wrote in message
news:N2******** ********@newsre ad1.news.atl.ea rthlink.net...

"Paul Hatcher" <pa**********@o nline.nospam> wrote in message
news:ef******** ******@tk2msftn gp13.phx.gbl...
Sorry to post this again - I didn't use my MSDN alias previously...

I'm using a url rewriting mechanism to make my site's urls more
search-engine/user-friendly, so we have

http://www.mysite.com/links/1023.apx
which is actually internally mapped to
http://www.mysite.com/links.aspx?link=1023. This works fine and makes the
site look a lot cleaner.

Instead of using http://www.mysite.com/links/1023.apx could you use
something like http://www.mysite.com/1023.apx (or even better is
http://www.mysite.com/link-1023.aspx b/c it be easier to detect and more
SEO
friendly) and have that rewrite to
http://www.mysite.com/links.aspx?link=1023. Just a thought.

Mike

Nov 19 '05 #5

"Paul Hatcher" <pa**********@o nline.nospam> wrote in message
news:Oz******** ******@TK2MSFTN GP09.phx.gbl...
Mike

Thanks - why is http://www.mysite.com/link-1023.aspx more SEO friendly than http://www.mysite.com/links/1023.aspx, is it because the page name is not
all numeric?

I also thought of http://www.mysite.com/1023/link.aspx which is quite nice
naming

Paul

"vMike" <Mi************ @spamnotgewarre n.com.delete> wrote in message
news:N2******** ********@newsre ad1.news.atl.ea rthlink.net...

"Paul Hatcher" <pa**********@o nline.nospam> wrote in message
news:ef******** ******@tk2msftn gp13.phx.gbl...
Sorry to post this again - I didn't use my MSDN alias previously...

I'm using a url rewriting mechanism to make my site's urls more
search-engine/user-friendly, so we have

http://www.mysite.com/links/1023.apx
which is actually internally mapped to
http://www.mysite.com/links.aspx?link=1023. This works fine and makes the site look a lot cleaner.

Instead of using http://www.mysite.com/links/1023.apx could you use
something like http://www.mysite.com/1023.apx (or even better is
http://www.mysite.com/link-1023.aspx b/c it be easier to detect and more
SEO
friendly) and have that rewrite to
http://www.mysite.com/links.aspx?link=1023. Just a thought.

Mike

The more I think about it they are probably the same.

Mike
Nov 19 '05 #6
Paul,

I've contacted the certain dev tester on this function and send them the
repro code, they're currently investigating on it. I'll update you as soon
as I got any feedback from them. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #7
Hi Paul,

As got from our DEV Tester, the problem is raised in the
Context.Rewrite Path method, so we're currently contacting the dev test of
that function to see whether they've any action plan on this. I just post
this message to let you know we're still keeping focus on this. Thanks for
your understanding.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #8
Hi Paul,

Sorry for keep you waiting. After some further contacting with our dev/test
guys, they've addressed this problem as a known limitation of the current
ASP.NET(1.x).

In Whidbey, we introduced 2 new API to work around this problem:
public void RewritePath(Str ing path, bool rebaseClientPat h);
public void RewritePath(Str ing filePath, String pathInfo, String
queryString, bool setClientFilePa th);

So currently, we may need to manually call Control.Resolve Url to corrently
parse the relative path. Sorry for the inconvenience it brings you.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 19 '05 #9
Can you give me an example of how you would do this in practice, i.e. does
this mean I need to create derived controls so that I can correctly override
the behaviour?

Paul

"Steven Cheng[MSFT]" wrote:
Hi Paul,

Sorry for keep you waiting. After some further contacting with our dev/test
guys, they've addressed this problem as a known limitation of the current
ASP.NET(1.x).

In Whidbey, we introduced 2 new API to work around this problem:
public void RewritePath(Str ing path, bool rebaseClientPat h);
public void RewritePath(Str ing filePath, String pathInfo, String
queryString, bool setClientFilePa th);

So currently, we may need to manually call Control.Resolve Url to corrently
parse the relative path. Sorry for the inconvenience it brings you.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #10

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

Similar topics

7
2780
by: Doug | last post by:
If I were to write an include with a relative path like include("../conf/config.php"); What is the use? As far as I understand it, the path is relative to the first script that is called by php. In other words, if the current working directory is /www/ and you were
5
4115
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it becomes increasingly difficult to ball park the folder when you go deeper and wider down:
2
1855
by: Joe | last post by:
Hi, can someone tell me how to set up relativ paths in VS2003 C++ ? I have some source with a tree directory structure that segments include files in various directories: #include "../include/config.h" /* Keep this first */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include "../include/complex.h" #include "../include/su3.h"
0
1302
by: Paul Hatcher | last post by:
I'm using a url rewriting mechanism to make my site's urls more search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx which is actually internally mapped to http://www.mysite.com/links.aspx?link=1023. This works fine and makes the site look a lot cleaner. The problem I'm having is with controls on the target page. I render all the urls as root relative so that I'm independent of whether I'm a root web or an...
8
2607
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the path can take the form of the following: 1. /directory/images/xyz.gif (works fine) 2. http://localhost:1234/www.mytestwebsite.com/directory/images/xyz.gif (doesn't work) 3. http:///www.someremotesite.com/directory/images/abc.gif (doesn't work)
1
2356
by: Anees | last post by:
hi i was trying to implement mode rewrite option in a blog site. i used the lines for listing the posts by its topic category as #List by Category RewriteRule ^Topics/(+)$ index.php?cat=$1 #With page navigation option RewriteRule ^Topics/(+)/(*)$ index.php?cat=$1&start=$2
15
6472
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
2
4305
by: BD | last post by:
Hi there. Using 8.2 on Windows. I have a situation where I have a db backup, which I want to deploy to a group of developer workstations. The target directory for the database files will be consistent, but the location that the backup file is on may vary. I have gone through the entire backup and restore process, and it
2
4311
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like dir1/dir2/dir3/dir4/dir5/file.txt
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10373
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.