ASP.NET MVC Encoding Issue -


i have asp.net mvc app. app passing name to/from database. i've discovered bug associated ampersands (&).

in database, see name "a & w".

i displaying value in ui using following:

<input id="name" name="name" value="@html.raw(model.name)" /> 

when view source, can see following html gets rendered in browser.

<input id="name" name="name" value="a & w" /> 

so far, good. however, when click save, , set breakpoint in controller action, can see name property on model "a & w". what's worse is, everytime save it, additional amp values added.

how remedy this?

thanks!

i had similar problem, used allowhtml attribute on property in model.

[allowhtml] public string name { get; set; } 

if aren't using code first, can apply attribute on top of action also:

[httppost] [allowhtml] [validateantiforgerytoken] public actionresult modify(modelclass model) {} 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -