I am new in MVC4 vb.net. I faced this error when I run my program.
"MissingMemberException was unhandled by user code.
Overload resolution failed because no accessible 'Chars' accepts this number of arguments."
Hereby shows my code:
HelloWorldController.vb
Public Function Welcome(name As String, Optional numTimes As Integer = 1) As ActionResult
ViewBag.Message = "Hello" & name
ViewBag.NumTimes = numTimes
Return View()
End Function
Welcome.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%ViewBag.Title = "Welcome"%>
<h2>Welcome</h2>
<ul>
<%For i = 0 To ViewBag.NumTimes-1%>
<li> <%ViewBag.Message()%> </li> //error
<%Next i%>
</ul>
</asp:Content>
Please explain to me why this will happen. Thank in advance.
The problem is <%ViewBag.Message()%>
Change it to <%= ViewBag.Message %>
.