I have 2 ASP.NET applications. Let’s say App1 and App2.
From App1, when I call Server.MapPath(“/App2”) I get the physical path of the App2 application.
When I change the path of App2 in IIS and I call Server.MapPath(“/App2”) again from App1, I get the same result.
I have to restart App1 for it to notice then change.
Is there something I can do about this without restarting App1?
The calls to
Server.MapPath()are likely being cached for performance, although there seems to be no documentation which alludes to this fact.You can bypass this with the following code
Disclaimer – This is a massive hack, but it does the job
Server.MapPath("/App2/" + Guid.NewGuid()).Substring(0,Server.MapPath("/App2/" + Guid.NewGuid()).Length-36)So yes, there is something you can do about this without restarting App1, but you probably will not want to do it.