安装 VS 2013 + .Net 4.5.1 后在 MVC 视图中显示垃圾标签 [英] Garbage tags showing up in MVC views after installing VS 2013 + .Net 4.5.1

查看:25
本文介绍了安装 VS 2013 + .Net 4.5.1 后在 MVC 视图中显示垃圾标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 ASP.Net MVC 4 应用程序中,有几个地方我们要么手动将视图渲染为字符串,要么拦截渲染管道的某些部分.例如:

In my ASP.Net MVC 4 application, there are several places where we are either manually rendering a view to a string or intercepting some part of the rendering pipeline. For example:

    public static string RenderPartialViewToString(Controller controller, string viewName, object model)
    {
        controller.ViewData.Model = model;
        try
        {
            using (System.IO.StringWriter sw = new System.IO.StringWriter())
            {

                var viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
                var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
                viewResult.View.Render(viewContext, sw);
                viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View);

                return sw.GetStringBuilder().ToString();

            }
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
    }

然而,截至今天,在使用 .Net 4.5.1 安装 Visual Studio 2013 预览版后,我们注意到返回给这些函数的 HTML 包含一堆垃圾/调试标签.例如以下:

However, as of today, after installing the Visual Studio 2013 preview with .Net 4.5.1, we have noticed that the HTML returned to these functions contains a whole mess of garbage/debugging tags. such as the following:

<$A$> <$B$><$C$> <$D$> class="dashboard-content jobs-view active-jobs-view"
<$E$> data-activity-type="<$F$>Active<$G$>"<$H$>> <$I$> <$J$><$K$><$L$> 
class="content-header" <$M$>> <$N$> <$O$><$P$> <$Q$> class="event-carousel-content"
<$R$>> <$S$> <$T$><$U$> <$V$> class="navbar candidate-summary-toolbar"<$W$>> 
<$X$> class="navbar-inner"<$Y$>> <$Z$> class="nav-collapse collapse"<$a$>>

它们出现的地方似乎没有任何押韵或理由,只是标签的字母每次增加一个.不过,这些标签似乎不会在正常页面生命周期中进入响应流,但只有在我们手动渲染它们或以某种方式拦截管道时才会出现.

There doesn't seem to be any rhyme or reason to where they show up, except that the letter of the tag increases by one each time. These tags don't seem to make it to the response stream during the normal page lifecycle, though - only when we render them manually or intercept the pipeline somehow.

有人知道这些标签是什么、它们来自哪里以及如何去除它们吗?

Does anybody have any idea what these tags are, where they came from and how to get rid of them?

谢谢!

推荐答案

我们正在考虑解决这个问题,但现在您应该通过工具栏按钮下拉菜单或通过在 web.xml 中设置 debug="false" 禁用浏览器链接.配置.

We are looking at fixing this, but for now you should just disable Browser Link either through the toolbar button dropdown or by setting debug="false" in web.config.

这篇关于安装 VS 2013 + .Net 4.5.1 后在 MVC 视图中显示垃圾标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆