Server.Transfer Virtual Directory Problems

  • Thread starter Thread starter Webmills
  • Start date Start date
W

Webmills

Has anyone come across the problem that I am experiencing?

I have a master page using four or five Hyperlink controls, each with
an ImageUrl. The ImageUrl is specified using a virtual directory path,
such as ImageUrl = "~/Images/Main.gif".

I have a child page in a sub directory, images all appear to be
correct. However, if I use a Server.Transfer to transfer to a different
child page in a different sub directory or at the root level, the
ImageUrl path does not update correctly. The hyperlink ImageUrl points
to an invalid directory. However the hyperlink NavigateUrl is always
correct, even though this also makes use of a virtual directory path.

To get the graphics to work again I need to physically refresh the page
with the F5 key.

Sound like an ASP.NET bug?

If I use a Response.Redirect rather than a Server.Transfer then it all
works as expected.

James
 
I don't think it's a bug - the problem you're having is easily
explained if you look at the difference between Server.Transfer (use
current request state on a different page) and Response.Redirect(send a
new request to somewhere else)

Because the transferred request has the original URL, it's mapping your
directories wrongly.

http://www.developer.com/net/asp/article.php/3299641
 
Back
Top