0

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...

Ferdi
  • 1
  • 1
    Are you sure? Put a dummy text file in the folder and see if you can see it. It should like a permissions issue. The *.cs files are not deployed if the site is "precompiled", but you should still have the .aspx files lying around..... – Ian G Jun 30 '11 at 09:39

1 Answers1

0

You may have to take it a step further and reflect of the precompiled dlls to see if they contain the class of the page you are trying to load

Daniel Powell
  • 8,143
  • 11
  • 61
  • 108
  • Well, that would be possible. But why doesnt't find the dummy files that are created by precompilation? They exist, so they have to be found...normally. – Ferdi Jul 01 '11 at 10:57