473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Relative paths on Application Error page

I have the following in the Page_Error method of my base class for my aspx
pages.

public void Page_Error(Object sender, EventArgs e)
{
Server.Transfer(Request.ApplicationPath + "/Error.aspx");
}

This works fine, however Error.aspx has some images on it that are document
relative, but if a page causes an error that is not in the same path as
Error.aspx then the image urls are wrong as the Server Context takes the
path from the location of the path that threw the error. I cant make the
urls root relative as this still wont work as the path moves and I also cant
have the full path as when deployed the root virtual directory may have a
different name.

I was trying to do something like this:

<LINK href='<%#AppPath("styles/style.css")%>' type="text/css"
rel="stylesheet" >

protected string AppPath(string file)
{
return Request.ApplicationPath + "/" + file;
}

but the output is:
<LINK href="" type="text/css" rel="stylesheet" >

MattC
Nov 18 '05 #1
1 1562
Can you not make the src have an absolute path instead?

"MattC" <m@m.com> wrote in message
news:Of**************@TK2MSFTNGP09.phx.gbl...
I have the following in the Page_Error method of my base class for my aspx
pages.

public void Page_Error(Object sender, EventArgs e)
{
Server.Transfer(Request.ApplicationPath + "/Error.aspx");
}

This works fine, however Error.aspx has some images on it that are document relative, but if a page causes an error that is not in the same path as
Error.aspx then the image urls are wrong as the Server Context takes the
path from the location of the path that threw the error. I cant make the
urls root relative as this still wont work as the path moves and I also cant have the full path as when deployed the root virtual directory may have a
different name.

I was trying to do something like this:

<LINK href='<%#AppPath("styles/style.css")%>' type="text/css"
rel="stylesheet" >

protected string AppPath(string file)
{
return Request.ApplicationPath + "/" + file;
}

but the output is:
<LINK href="" type="text/css" rel="stylesheet" >

MattC

Nov 18 '05 #2

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

Similar topics

7
2767
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...
5
4094
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...
2
2351
by: Alex | last post by:
Hi. I need some help on this. I have a user control (a header) in my root directory, and all my pages use that control. Then a created a folder (in my root directory) and put a new page inside it,...
2
1868
by: Steve Franks | last post by:
I am familiar with the fact that you have to use runat=server and links staring with "~/" to ensure proper mapping of paths to relative URLs when using master pages. However this does not seem to...
8
260
by: Paul Bromley | last post by:
I am trying to get somewhere with user controls and have come up against an obstacle with using relative paths. I have a dataset in my user control, and have tried to enter the path with the...
9
1737
by: Garann Means | last post by:
I have a subfolder under wwwroot set up as a virtual directory with its own application name in IIS. I pulled it down from Visual Source Safe and, on the machine where it's normally hosted, it...
2
1795
by: rjbr | last post by:
ASP.NET problem I have ASP.NET 1.1 application installed on 3 server Win2003/IIS6 Relative paths are being resolved in 2 of those but not on one dir structire /app/ /import
8
2590
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...
15
6434
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...
0
7002
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
7165
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,...
0
7205
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...
0
5462
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
4590
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
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.