As of recent, a few of my strongly typed views randomly (w/ zero code changes) decided that 'Model' was not a valid item … again – ZERO code changes. I simply opened my view and now it's broken … so logically I deleted the view and created a new one – still broken. Has anyone else come across this issue using MVC? A simple example is below
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of IEnumerable (Of Project.Library.Entity.User))" %>
<table id="tblUser" cellspacing="0" cellpadding="0" border="0">
<tr>
<th>Username</th>
</tr>
<% For Each item In Model%>
<tr>
<td>
<%=Html.Encode(item.Username)%>
</td>
</tr>
<% Next%>
</table>
The actual error shows up in the view – under the word "Model" is a red line and when I hover over this (in any of my partial views – strongly typed) it says "Name 'Model' is not declared"
Best Answer
'Model' is a property of the ViewUserControl class, so when it's marked as not declared this may mean the following:
Hope this will help.