【发布时间】:2014-09-09 05:02:45
【问题描述】:
我已经重写了 Sharepoint 页面的 Render 方法,以从发送到客户端浏览器的 html 中删除一些脚本标记,如下所示:
protected override void Render(HtmlTextWriter originalWriter)
{
string content = string.Empty;
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
{
//render the page to my temp writer
base.Render(htmlWriter);
htmlWriter.Close();
//get page content that would normally be sent to client
content = stringWriter.ToString();
stringWriter.Close();
}
}
//replace the script tag
Regex regex = new Regex(@"<script>.*RTE_ConvertTextAreaToRichEdit.*<"+"/script>");
content = regex.Replace(content, string.Empty);
//write modified html to the original writer
originalWriter.Write(content);
}
在此更改之后发生了一些奇怪的事情:通常位于右上角并显示“欢迎 XXX”的页面部分未正确显示。当我查看页面的源代码时,此文本在 HTML 标记之前写入 - 在任何 html 开始之前。我不知道过去两天发生了什么。
你有什么想法吗,有没有人遇到过类似的问题?
【问题讨论】:
标签: asp.net sharepoint