1

Has anyone come across this before?

Following a very simple MVC tutorial I return a string from a controller. The string is generated using this code:

    public string Welcome(string name, int ID = 1)
    {
      return HttpUtility.HtmlEncode("Hello " + name + ", ID: " + ID);
    }

In Google Chrome (the top browser in the screenshot) the string looks fine but in Microsoft Edge (second browser) the string has had the space removed at the start so it looks like this: HelloTestName

The response as taken from Postman is below the screenshot.

enter image description here

Headers

Cache-Control →private
Content-Encoding →gzip
Content-Length →138
Content-Type →text/html; charset=utf-8
Date →Tue, 17 Jan 2017 10:36:56 GMT
Server →Microsoft-IIS/10.0
Vary →Accept-Encoding
X-AspNet-Version →4.0.30319
X-AspNetMvc-Version →5.2
X-Powered-By →ASP.NET
X-SourceFiles →=?UTF-8?B?QzpcVXNlcnNcbWVha2luclxEZXNrdG9wXE1WQy1UZXN0c1xCcmlkZ2V3YXktUmVwb3J0c1xCcmlkZ2V3YXktUmVwb3J0c1xoZWxsb3dvcmxkXHdlbGNvbWVcMw==?=

Body

Hello TestName, ID: 3
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Sparked
  • 844
  • 10
  • 25
  • The MVC part is irrelevant. What is the actual, entire content you return, including content headers? – CodeCaster Jan 17 '17 at 10:34
  • 2
    So you're not actually sending HTML, the browser goes into "tag soup" or "quirks mode". Try sending actual HTML. See for example https://developer.mozilla.org/en-US/docs/Quirks_Mode_and_Standards_Mode and [What's a valid HTML5 document?](http://stackoverflow.com/questions/9797046/whats-a-valid-html5-document). – CodeCaster Jan 17 '17 at 10:46
  • Okay, that appears to be the answer. Although I am following a tutorial on Microsoft's asp.net site: https://www.asp.net/mvc/overview/getting-started/introduction/adding-a-controller, it appears they are using Chrome in the screenshots. Thank you for your help. – Sparked Jan 17 '17 at 11:03

0 Answers0