dotnet path symbol

  • Thread starter Thread starter LP
  • Start date Start date
L

LP

Hi all,
When I choose a destination url a ~ symbol is inserted for me eg
~\apppath\abc.aspx. But when I run the aspx, it can't find the file
abc.aspx. but if I type the full pathname it can find the file eg
c:\inetpub\ccc\abc.aspx. any idea?

thanks
 
App path root symbol (~) is resolved to application root folder and they are
resolved only when used on server controls.
 
If directing a web client, use Response.Redirect(ResolveUrl("~/abc.aspx"));

If executing the .aspx file from the server without redirecting the client,
try:
Server.Execute(ResolveUrl("~/abc.aspx"));

If accessing the .aspx file itself directly on the server, one would ask
why? I can understand this for an .xml file, but why read an .aspx directly?
At any rate, you can read files on the server using:

//myFile = "~/abc.xml"
if (myFile.StartsWith("~")) myFile = myFile.Replace("/", "\\")
.Replace("~", Request.PhysicalApplicationPath);

or,

myFile = Request.MapPath(myFile);


Jon
 
Back
Top