In my ASP.NET MVC4 application I have model that is defined like this:
public class Employee : BaseObject
{
[JsonIgnore]
public string FirstName { get; set; }
[JsonIgnore]
public string LastName { get; set; }
[JsonIgnore]
public string Manager { get; set; }
public string Login { get; set; }
...
}
When I return this object using ApiController I get correct object without fields that have JsonIgnore attribute, but when I try adding same object inside cshtml file using below code I get all fields.
<script type="text/javascript">
window.parameters = @Html.Raw(@Json.Encode(Model));
</script>
It looks like @Json.Encode is ignoring those attributes.
How can this be fixed?
[HiddenInput(DisplayValue = false)]