如何为asp.net mvc编写预渲染事件? 实际上我的问题是我需要在IE10中制作我的网页的文档标准 IE9 +标准,因为默认情况下它是IE7 +标准,由于此问题我的应用程序无法按要求工作。
答案 0 :(得分:1)
如何为asp.net mvc编写预渲染事件?
您可以创建一个简单的ActionFilter - Reference taken from here
public class UpdateFilter : ActionFilterAttribute
{
private HtmlTextWriter tw;
private StringWriter sw;
private StringBuilder sb;
private HttpWriter output;
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
sb = new StringBuilder();
sw = new StringWriter(sb);
tw = new HtmlTextWriter(sw);
output = (HttpWriter)filterContext.RequestContext.HttpContext.Response.Output;
filterContext.RequestContext.HttpContext.Response.Output = tw;
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
string response = sb.ToString();
output.Write(response);
}
}
当您请求页面时,您可以在OnResultExecuted()
中自定义您的回复html。当你设置一个断点时,它会是这样的 -