Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange whitespace appearing in MVC4 Razor View
    primarykey
    data
    text
    <p>I'm developing an app in ASP.Net MVC4 and am having a strange issue with whitespace. I've developed plenty of MVC3 sites with Razor without this issue.</p> <p>Here's my template cshtml file:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;HF - Content Management - @ViewBag.Title&lt;/title&gt; &lt;link href="@Url.Content("~/content/bootstrap/bootstrap.min.css")" rel="stylesheet" /&gt; @Styles.Render("~/bundles/css/hf-cms-logged-in") &lt;/head&gt; &lt;body&gt; @Html.Partial("Partials/NavBar") &lt;div class="container"&gt;@RenderBody()&lt;/div&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/scripts/bootstrap/bootstrap.min.js")"&gt;&lt;/script&gt; @Scripts.Render("~/bundles/js/validation") &lt;script src="@Url.Content("~/scripts/hf-cms.js")"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Note the line with the RenderBody() call - there's no extraneous whitespace here.</p> <p>When I call an action, the rendered body is prepended with some whitespace which I can't see that I've added, and can't seem to get rid of. I call an action with no logic, it only returns the following view:</p> <pre><code>@{ ViewBag.Title = "Dashboard"; } &lt;h1&gt;Dashboard&lt;/h1&gt; </code></pre> <p>It's definitely using the correct template (specified in my _ViewStart.cshtml)</p> <p>Viewing the page in Google Chrome, the source shows extra whitespace. See the image below:</p> <p><img src="https://i.stack.imgur.com/mUXB2.jpg" alt="Whitespace shown in Google Chrome developer tools"></p> <p>A similar issue can be seen in IE10. This is obviously affecting the design. I've tried using <a href="https://github.com/meleze/Meleze.Web" rel="nofollow noreferrer">Meleze.Web</a> to strip out any extra whitespace, but whitespace still remains.</p> <p>I'm at a loss with this one, as it's a relatively simple site so far, there's nothing funky going on yet, so I can't see where this whitespace is coming from.</p> <p>Has anybody else seen this with MVC4 or Razor before?</p> <p>Edit: I've tried removing all stylesheets and script files, the whitespace still exists.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload