使用.NET中的MVC默认命名空间的观点,而不使用进口? [英] Using default namespaces in .NET MVC for views without using import?

查看:87
本文介绍了使用.NET中的MVC默认命名空间的观点,而不使用进口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置的意见,能够引用像System.Web.Mvc命名空间而不必做<%@导入命名空间=System.Web.Mvc%>?我记得看到这个地方,但我的谷歌技能的时刻失败的我。

How do you configure the views to able to reference a namespace like System.Web.Mvc without having to do <%@ Import Namespace="System.Web.Mvc" %>? I remember seeing this somewhere but my google skills are failing me at the moment.

推荐答案

您可以将它们添加在web.config中?不知道这部作品在MVC,但...

Can you add them in web.config? Don't know if this works in MVC, though...

<configuration>
 <system.web>
    <pages>
      <namespaces>
        <add namespace="Foo.Blop" />
        <add namespace="Bar.Whatever"/>
      </namespaces>
    </pages>  
 </system.web>
</configuration>

(更新 - 似乎做工精细;-p)

(update - seems to work fine ;-p)

这篇关于使用.NET中的MVC默认命名空间的观点,而不使用进口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆