检查 ASP.NET 页面是否存在预编译页面
我想在打开 ASPX 文件之前检查它是否存在,因为它是动态加载的。通过使用以下代码,这应该很容易:
string directoryPath = Server.MapPath("~/Forms/");
string filePath = directoryPath + nameOfFile + ".aspx";
if (File.Exists(filePath))
{
Response.Redirect("~/Forms/" + nameOfFile + ".aspx");
}
对于 IIS 中未由 aspnet_compiler.exe 预编译的网站,该代码可以正常工作。但如果我预编译它们(即使是同一个网站),页面就找不到了。通过预编译它们,磁盘上仍然存在虚拟文件,因此应该可以在文件系统上找到它们。
也许有人可以帮助我解决这个问题......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要更进一步并反映预编译的 dll,以查看它们是否包含您尝试加载的页面的类
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