Reputation: 2811
So I have a ViewModel in the 'models' folder of my Mvc project with a namespace of 'Web.Models' (My Mvc project is called 'Web') I think its worth mentioning I have 3 other projects in my solution: Domain, Test, and Tasks. The view model is assigned properties from classes in my Domain.Entities folder. I can create a new instance of my viewmodel in my controller when I add the namespace in my contoller.
using Web.Models;
When I create the view however, it cant seem to import the namepace. It actually prompts me to add the namespace via 'alt+ enter' or 'ctrl + dot' and it still says that it cant resolve the object.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Web.Models.MyViewModel>" %>
I've also tried adding a global reference to the namespace in my Web.config, but no luck. Any suggestions?
Upvotes: 8
Views: 13114
Reputation: 2811
Found out it had to do with my build of ReSharper, I updated to 5.1 and it took care of what I guess was some sort of a "cache bug".
Upvotes: 1
Reputation: 171411
You can add it in your web.config under system.web/pages/namespaces
. E.g.,
...
<namespaces>
...
<add namespace="Web.Models"/>
</namespaces>
...
Upvotes: 9
Reputation: 4209
First, compile your app, then make sure that MyViewModel is public.
Upvotes: 1