How do I import a namespace in Razor View Page?

后端 未结 11 1579
迷失自我
迷失自我 2020-11-22 11:03

How to import a namespace in Razor View Page?

11条回答
  •  天命终不由人
    2020-11-22 11:40

    Depending on your need you can use one of following method:

    • In first line/s of view add "using your.domainName;" (if it is required in specific view only)
    • if required in all subsequent views then add "using your.domainName;" in _ViewStart.cshtml. You can find more about this in: Where and how is the _ViewStart.cshtml layout file linked?

    • Or add Assembly reference in View web.config as described by others explained in: How do you implement a @using across all Views in Asp.Net MVC 3?

提交回复
热议问题