Re: server.transfer and current directory

Discussion in 'ASP .Net' started by bruce barker, May 14, 2004.

  1. bruce barker

    bruce barker Guest

    the browser requested /MySite/Folder/folder.aspx, when it sees a relative
    path to an image (src="images/myimage.jpg"), the browser knows to request
    /MySite/Folder/images/myimage.jpg.

    you need to change all your image and style path to be absolute rather than
    relative (src="~/images/myimage.jpg")


    "Gerard" <> wrote in message
    news:...
    > I'm having a problem with the current directory on an ASP.NET site using

    Server.Transfer. I have isolated the problem on a 2-pages site (quite
    stupid, but it shows the problem).
    >
    > I have a root page on my site, called /MySite/root.aspx.
    > On that page, I have a link to another aspx page located in a subfolder,

    say /MySite/Folder/folder.aspx.
    > Now, in the Page_Load event of the folder.aspx page (or after I click on a

    button), I do a Server.Transfer("/MySite/root.aspx") to go back to the root
    page.
    >
    > If I use WebForm controls on the root.aspx file (images, links), they show

    correctly. But if I use html tags (<img>), the path is wrong when I go back.
    Also, the <link> tag to a style sheet is wrong (it points to the
    sub-folder). It seems that the current directory for ASP.NET is still the
    folder directory, not the root, although I did a Transfer back to the root.
    >
    > Is there a way to set the current directory back to the root? (please,

    don't tell me to use Response.Redirect that solves the problem but is not
    what I need to use).
    >
    > Gerard.
    >
     
    bruce barker, May 14, 2004
    #1
    1. Advertising

  2. Bruce

    Thanks for the tip. I still have a problem: on my development system, the root directory is a folder in my web site (ie /MySite) while on the system where my application is hosted it is a web site (ie /). Does that mean I have to change each url each time I copy my application to the host computer? I guess an alternative would be to create a web site on my development system, but I am running Windows XP that only allows one default web site

    Any suggestions are welcome

    Gerard.
     
    =?Utf-8?B?R2VyYXJk?=, May 14, 2004
    #2
    1. Advertising

  3. bruce barker

    bensonr

    Joined:
    Sep 8, 2010
    Messages:
    1
    Server.Transfer

    Below is the sample code for your issue. Just add the attribute runat="server" inside the img tag..


    <img runat="server" src="your image path" />

    hope this helps you....
     
    bensonr, Sep 8, 2010
    #3
    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. Adrian Bezzina
    Replies:
    0
    Views:
    521
    Adrian Bezzina
    Aug 7, 2003
  2. Webmills
    Replies:
    1
    Views:
    1,944
    Flinky Wisty Pomm
    Apr 2, 2006
  3. =?Utf-8?B?YWxiZXJ0b3Nvcmlh?=

    Server.Transfer fails because httpcontext.current = nothing

    =?Utf-8?B?YWxiZXJ0b3Nvcmlh?=, Oct 24, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    1,322
    =?Utf-8?B?YWxiZXJ0b3Nvcmlh?=
    Oct 25, 2007
  4. Jim
    Replies:
    1
    Views:
    945
    Aaron Bertrand - MVP
    Jan 28, 2004
  5. Replies:
    3
    Views:
    184
Loading...

Share This Page