2008-12-09 149 views

回答

31

尝试在你的ASPX/ASCX文件中使用

<%@ import namespace='your namespace' %> 

,你也可以尝试导入您的命名空间在web.config

<system.web> 
    <pages> 
    <namespaces> 
     <add namespace='you namespace' /> 
    </namespaces> 
    </pages> 
</system.web> 
2

你记得包括组装呢?例如。像这样:

// system.web/compilation/assemblies 
<add assembly="Microsoft.Web.Mvc"/> 
0

假设这是你的.Cs文件说

命名空间MVCTest.Controller {

public class Utility 

{ 
    public static void func1() 
    {} 
} 

}

尝试通过调用函数:Utility.func1()

10

添加进口声明如果您使用的是ASP.NET(C#)发动机:

<%@ Import Namespace="My.Namespace.Path" %> 

<html goes here> 
    ... 
</html> 

添加使用陈述你的看法,如果你使用的是剃刀引擎:

@using My.Namespace.Path 

@{ 
    ViewBag.Title = "My Page"; 
    ... 
} 

<html goes here> 
    ... 
</html goes here>