I'm attempting to create a strongly-typed view based on a class from another assembly. For whatever reason though, my Razor view doesn't seem to have any visibility of other assemblies referenced on my project. e.g.
@model MyClasses.MyModel
results in the error in Visual Studio 2010, "The type or namespace name MyClasses
could not be found (are you missing a using directive or an assembly reference?)."
The same class referenced in the standard view engine works fine. I have the same trouble trying to reference the class in the body of my view.
Am I missing something about Razor or do I need to reference the assembly some other way?
Best Answer
There is a new configuration section that is used to reference namespaces for Razor views.
Open the
web.config
file in yourViews
folder, and make sure it has the following:Alternatively, you can add using statements to your shared layout:
After editing the Web.config, restart Visual Studio to apply the changes.