in asp.net mvc 5 application have models in namespace myapp.models. use model inside view, e.g. tell view model should use @model userloginmodel, have import namespace using myapp.models.
thats not big deal prefer include namespace automatically in every of views avoid redundant importing in every view. found out web.config file in views-folder seems right job
<system.web.webpages.razor> <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=5.1.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> <pages pagebasetype="system.web.mvc.webviewpage"> <namespaces> <add namespace="system.web.mvc" /> <add namespace="system.web.mvc.html" /> <add namespace="system.web.routing" /> <add namespace="system.web.optimization"/> <add namespace="myapp" /> <add namespace="myapp.models"/> </namespaces> </pages> but not working. of pre-generated visual studio. added <add namespace="myapp.models"/> models.
on found similar question asker should work using views/web.config file tried , answears follow question specified new beta of asp.net mvc 6. i'm using mvc 5.1.2 , cant make work, can't find view without including namespace @using in view.
you can globally add namespaces using new _viewimports.cshtml. example of contents is:
@using microsoft.aspnet.identity @addtaghelper "*, microsoft.aspnet.mvc.taghelpers"
Comments
Post a Comment