I would like to check if an ASPX file exists before I open it because it is loadded dynamically. That should be quite easy by using the following code:
string directoryPath = Server.MapPath("~/Forms/");
string filePath = directoryPath + nameOfFile + ".aspx";
if (File.Exists(filePath))
{
Response.Redirect("~/Forms/" + nameOfFile + ".aspx");
}
For websites in IIS that are not precompiled by aspnet_compiler.exe that works. But if I precompile them (even the same website) the pages are not found anymore. By precompiling them there are still dummy files on the disk so that they should be found on the filesystem.
Perhaps someone can help me with this...