【发布时间】:2014-05-19 07:41:46
【问题描述】:
我正在尝试使用 javascript 捕获 http 并从中删除一些元素
它可以在 chrome 上运行,但不能在 IE 上运行。
void context_EndRequest(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
if (context.Request.Url.AbsolutePath.Contains(@"/account/"))
{
HttpContext.Current.Response.Write(@"<script type='text/javascript'> document.getElementById('swtch').style.display = 'none';</script>");
}
}
我试过了:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Write(@"<script type='text/javascript'> document.getElementById('swtch').style.display = 'none';</script>");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
它会编写脚本,但也会清除整个 html,并且我正在寻找的对象不再存在。
该站点在 IIS 上运行,我设法对其进行了调试,它转到了代码,但在最终结果中我没有看到脚本,我尝试了不同的脚本,仍然没有运气
【问题讨论】:
标签: c# iis httpcontext