Friday, April 26, 2013

The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.IO.TextWriter.Write(char[])'


In ASP.NET MVC 2 you might get the above error due to the model is referencing a null value. In my case i got this error with the below code in my view.

<% foreach (var item in Model) { %>
<tr>
<td>
<%: item.Fax %>
</td>
</tr>
<% } %>

Using Html.Encode i solved my issue.
<% foreach (var item in Model) { %>
<tr>
<td>
<%: Html.Encode(item.Fax) %>
</td>
</tr>
<% } %>

No comments:
Write comments
Recommended Posts × +