我想在打开它之前检查一个 ASPX 文件是否存在,因为它是动态加载的。使用以下代码应该很容易:
string directoryPath = Server.MapPath("~/Forms/");
string filePath = directoryPath + nameOfFile + ".aspx";
if (File.Exists(filePath))
{
Response.Redirect("~/Forms/" + nameOfFile + ".aspx");
}
对于 IIS 中没有由 aspnet_compiler.exe 预编译的网站,它可以工作。但是如果我预编译它们(即使是同一个网站),页面也找不到了。通过预编译它们,磁盘上仍然存在虚拟文件,因此应该可以在文件系统上找到它们。
也许有人可以帮我解决这个...