简体   繁体   中英

Check if ASP.NET page exists with precompiled pages

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM