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?
You can add it in your web.config under system.web/pages/namespaces
. E.g.,
...
<namespaces>
...
<add namespace="Web.Models"/>
</namespaces>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With