Garbage tags showing up in MVC views after installing VS 2013 + .Net 4.5.1

不问归期 提交于 2019-12-09 03:43:53

问题


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();
        }
    }

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?

Thanks!


回答1:


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.




回答2:


Apparently I am not the only person having this problem. Found the answer here:

Page uses an invalid or unsupported form of compression when debugging ASP.NET MVC app with Visual Studio 2013 Preview

It looks like you need to disable the browser-link option in visual studio. Hopefully there is a more permanent fix possible in the future because browser-link looks cool.



来源:https://stackoverflow.com/questions/17386555/garbage-tags-showing-up-in-mvc-views-after-installing-vs-2013-net-4-5-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!