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 may get this error due to null value referencing model. In my case, I had the following code in my view.

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

Using Html.Encode I managed to solve the issue.

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

No comments:
Write comments
Recommended Posts × +