Relative paths on Application Error page

Discussion in 'ASP .Net' started by MattC, Aug 24, 2004.

  1. MattC

    MattC Guest

    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
     
    MattC, Aug 24, 2004
    #1
    1. Advertising

  2. MattC

    Janaka Guest

    Can you not make the src have an absolute path instead?

    "MattC" <> wrote in message
    news:...
    > 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
    >
    >
     
    Janaka, Aug 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?R2FyYW5uIE1lYW5z?=

    application relative paths not working

    =?Utf-8?B?R2FyYW5uIE1lYW5z?=, Apr 13, 2006, in forum: ASP .Net
    Replies:
    9
    Views:
    2,087
    Jeff Dillon
    Apr 17, 2006
  2. Jsp
    Replies:
    2
    Views:
    2,920
  3. rjbr
    Replies:
    2
    Views:
    528
    =?Utf-8?B?QWxveXNpdXMgTWFyaWEgU2VsdmFt?=
    Jul 12, 2006
  4. Noah
    Replies:
    5
    Views:
    826
  5. Ohad Lutzky

    Paths, gentleman, paths

    Ohad Lutzky, Nov 6, 2006, in forum: Ruby
    Replies:
    2
    Views:
    217
    David Vallner
    Nov 7, 2006
Loading...

Share This Page