MapPath/PhysicalApplicationPath change on reload
MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 13:08:00 von IDC
Hi,
I have a problem accessing files in my ASP.NET 3.5 project after I publish
it. When I load a page for the first time Request.PhysicalApplicationPath
returns the correct directory (C:\inetpub\wwwroot\...) but on reloading the
page (or accessing the same page with different parameters) I end up getting
c:\windows\system32\inetsrv\...
Of course File.Exists() fails for that directory. Is there a way (other than
hardcoding) to always get the real physical application path
(C:\inetpub\wwwroot\...) so I can check it's subdirectories for necessary
files?
Thanx.
RE: MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 13:18:00 von pbromberg
This doesn't compute. There must be something else going on, because
Server.MapPath can *only* return a physical path that lies in the web
application vroot.
-- Pete
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"IDC" wrote:
> Hi,
> I have a problem accessing files in my ASP.NET 3.5 project after I publish
> it. When I load a page for the first time Request.PhysicalApplicationPath
> returns the correct directory (C:\inetpub\wwwroot\...) but on reloading the
> page (or accessing the same page with different parameters) I end up getting
> c:\windows\system32\inetsrv\...
> Of course File.Exists() fails for that directory. Is there a way (other than
> hardcoding) to always get the real physical application path
> (C:\inetpub\wwwroot\...) so I can check it's subdirectories for necessary
> files?
>
> Thanx.
RE: MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 13:39:00 von IDC
"Peter Bromberg [C# MVP]" wrote:
> This doesn't compute. There must be something else going on, because
> Server.MapPath can *only* return a physical path that lies in the web
> application vroot.
It's the function I use and the result I get :-/
RE: MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 15:07:02 von pbromberg
Post "just enough" working sample code for a helpful reader to be able to
reconstruct your issue.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"IDC" wrote:
>
>
> "Peter Bromberg [C# MVP]" wrote:
> > This doesn't compute. There must be something else going on, because
> > Server.MapPath can *only* return a physical path that lies in the web
> > application vroot.
>
> It's the function I use and the result I get :-/
RE: MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 15:33:01 von IDC
The code behind file contains:
protected void Page_Load(object sender, EventArgs e)
{
....
if (System.IO.File.Exists(Server.MapPath("videodata/c123.xml")) )
{
....
}
....
}
works fine the first time this page is loaded but on a reload it crashes with:
Could not find a part of the path
"c:\windows\system32\inetsrv\videodata\123.xml"
RE: MapPath/PhysicalApplicationPath change on reload
am 14.01.2008 15:34:03 von IDC
The code behind file contains:
protected void Page_Load(object sender, EventArgs e)
{
....
if (System.IO.File.Exists(Server.MapPath("videodata/c123.xml")) )
{
....
}
....
}
works fine the first time this page is loaded but on a reload it crashes with:
Could not find a part of the path
"c:\windows\system32\inetsrv\videodata\123.xml"