Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unknown element" in Strongly typed View with Generic Model

I am having trouble defining generic models in razor views. Whenever I use a generic model, I get the following warning:

Unknown element 'string' or element cannot be placed here.

Example:

@model List<string>

While this doesn't cause any major errors, it's still very annoying. Is there a way to define a generic in a razor view that doesn't cause this warning?

Environment: VS 2013
ASP.NET MVC v5.1.2
Razor 3.1.1

like image 557
Dustin E Avatar asked Dec 26 '22 10:12

Dustin E


1 Answers

I was having the same problem, and it turns out that when I upgraded to the latest version of MVC, not all of my config elements were updated correctly. Changing Web.config in the following ways fixed this for me:

  1. Make sure any line mentioning System.Web.Mvc has the version number changed to 5.0.0.0.
  2. Make sure any line mentioning System.Web.WebPages.Razor has the version number changed to 3.0.0.0.
like image 118
StriplingWarrior Avatar answered Jan 05 '23 00:01

StriplingWarrior