Garbage tags showing up in MVC views after install

2019-02-27 10:45发布

问题:

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.