Question

In my C# MVC view code I have a a hidden input field

<input type='hidden'  name='foo' value='${r.data}'/>

On my local machine when testing it generates the html source.

<input type='hidden'  name='foo' value='bah'/>

On my production server the source it sends to the client is

<input type="hidden"  name="foo" value="bah"/>

It has replaced the single quotes ' for double quotes ". which will break if there is a double quote in the variable data.

Now I know I should be testing for html special chars or at least doing

<input type="hidden"  name="buttons" value="${r.data.Replace(@"""", "&quot;")}"/> 

Why the difference between local machine and production output?

Where is this getting changed is it part of the spark view engine, or part of the Response builder in C# but that doesn't make sense? The only thing I can think of is a difference with IIS and the VS2010 inbuilt web server?

The file encoding is the same on local and production UTF8, there are using same dlls. and same build type being Release.

Both single and double quotes should be permitted. Single vs Double quotes (' vs ")

This doesn't make any sense how this could be happening And I feel like I am losing my mind.

Was it helpful?

Solution

A similar Question was Posted here ASP.NET MVC 2 and sparkviewengine rendering single quotes to double quotes in html5 data- attribute (with an accepted anwser) probably not the same MVC Version, but probally the same Bug.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top