【发布时间】:2010-06-01 20:13:25
【问题描述】:
我正在创建一个自定义包含方法(加载)来检查文件是否存在。加载功能包括文件(如果存在)或发送电子邮件通知我链接断开(如果不存在)。我遇到的问题是如果包含文件包含服务器控件,它只是将它们显示为纯文本。如果我要尝试将包含文件添加到包含文件,这是一个问题。
在 default.aspx 我有:
<% ResourceMngr.load("~/Includes/menu.inc"); %>
在资源管理器中:
public static void load(String url) {
string file = HttpContext.Current.Server.MapPath(url);
if (System.IO.File.Exists(file))
{
HttpContext.Current.Response.Write(System.IO.File.ReadAllText(file));
}
else
{
String body = "This message was sent to inform you that the following includes file is missing: \r\n";
body += "Referrer URL: " + HttpContext.Current.Request.Url.AbsoluteUri + "\r\n";
body += "File Path: " + file;
MailUtil.SendMail("email@email.com", "Missing Includes File", body);
}
}
因此,如果“menu.inc”还包含<% ResourceMngr.load("~/Includes/test.inc"); %> 标签,它只会在页面上以纯文本形式将其打印出来,而不是尝试包含 test.inc,而页面上的所有其他 html 会完全显示为预期的。如何允许我的包含文件具有服务器控件?
【问题讨论】:
标签: c# asp.net controls include