asp.net mvc - Namespace in view

前端 未结 4 1138
失恋的感觉
失恋的感觉 2021-02-19 02:52

I place using namespace in a view code behind but i can\'t call any class of this name space in aspx.

In codebehind:

using MVCTest.Controller;

4条回答
  •  执笔经年
    2021-02-19 03:47

    Add the import statement If you are using the ASP.NET (C#) engine:

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

    OR

    Add the using statement to your view if you are using the Razor engine:

    @using My.Namespace.Path
    
    @{
        ViewBag.Title = "My Page";
        ...
    }
    
    
       ...
    
    

提交回复
热议问题