ASP.NET MVC Preview 5 - Html.Image helper has moved namespace

痞子三分冷 提交于 2019-12-10 14:51:33

问题


We've just updated ASP.NET from Preview 3 to Preview 5 and we've run into a problem with the Html.Image HtmlHelper in our aspx pages.

It seems that Html.Image has moved from System.Web.Mvc into Microsoft.Web.Mvc, and the only way we've found to access the helper now is to add an import statement to every .aspx page that uses it. All the other helpers can be accessed with using System.Web.Mvc; in the C# codebehind of a view master page, but this one seems to need an <@Import Namespace="Microsoft.Web.Mvc"> in every .aspx page.

Does anyone know of a way around this?


回答1:


You can add the namespace to pages in System.Web in you web config.

<pages validateRequest="false">
    <namespaces>
        <add namespace="Microsoft.Web.Mvc"/>        
    </namespaces>
</pages>


来源:https://stackoverflow.com/questions/114108/asp-net-mvc-preview-5-html-image-helper-has-moved-namespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!