I have extended HtmlHelper, then when trying to use it in partial view it doesn't show in intellisense, I have added the namespace to the web.config. the only way to get it to work was to add a using statement to the partial view. Am I missing something? I would prefer not to add using statements to every view using it.
问问题
454 次
1 回答
1
Ensure that you are editing the config file in your Views directory.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Your.Namespace.Goes.Here" />
</namespaces>
</pages>
</system.web.webPages.razor>
Also, sometimes you might need to close and reopen the .cshtml file or even restart Visual Studio.
于 2013-03-15T15:36:59.443 回答