if (!System.IO.File.Exists(Request.PhysicalPath))
{
string sRequestedUrl = Request.Path;
string sTargetUrl = GetRurl(sRequestedUrl);
Context.RewritePath(sTargetUrl, false);
}
GetRurl map real url on virtual url.
I get a problem with images ref. In the root dir i have a subdir called
images and in html code I have ref like these:
<img src="images/img.jpg">
or
<body background="images/back.jpg">
When the code transforms shop/books/one.html in content.aspx?id=123456 I
obtain an exception due to wrong path (shop/books/images/img.jpg instead
of images/img.jpg). If a use ref like ~/images/img.jpg I still obtain
wrong Request.PhysicalPath...
The url of my application is http://MySite/MyApp.
Can you help me?
Bye
Fransis
In my page i've two tag like these:
<link href="~/styles/style.css" rel="stylesheet" type="text/css" />
and
<body background="~/img/image.jpg" topmargin=0 bottommargin=0>
the property Request.PhysicalPath return a right value
"c:\\inetpub\\wwwroot\\myApp\\styles\\style.css" and a wrong value
"c:\\inetpub\\wwwroot\\myApp\\~\\img\\image.jpg".
Why? Can you help me?
if you us a ~path on a non-server control, its rendered as ~path, and thats
what the browser will send.
-- bruce (sqlwork.com)
take url
http://mysite/myapp/mypage/fake.htm
which is rewritten
http://mysite/myapp/mypage.aspx?id=fake
now if you use ~/images/image.gif, .net determines the current request is at
the base dir so it renders:
src="images/image.gif"
but the browser sees the before url. so when it requests the image it sends:
http://mysite/myapp/mypage/images/image.gif
because to it the base dir is "http://mysite/myapp/mypage"
you need to url the image requests also, calc the path in your code.
-- bruce (sqlwork.com)