Reputation: 1931
When I try to run this controller action, I get the error:
Compiler Error Message: CS0234: The type or namespace name 'ViewModels' does not exist in the namespace 'App.Models' (are you missing an assembly reference?)
Line 28: using App.Web.Mvc;
Line 29: using App.Models;
Line 30: using App.Models.ViewModels;
The problem is there is no reference to App.Models.ViewModels
in controller in the first place so I don't know why there is an error, the 30th line simple does not exists anywhere in my project!
Upvotes: 0
Views: 719
Reputation: 1931
Found out that Razor will add a reference to namespaces specified in Web.Config file in your views folder to the top of the complied files for your views. so just removed the reference in webconfig
Views/Web.config:
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="App.Models.ViewModels" />
</namespaces>
</pages>
</system.web.webPages.razor>
Upvotes: 1