How to import a namespace in Razor View Page?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
The first way is that use
@using
statement in.cshtml
files, that imports a namespace to current file only, and the second:In the "web.config" file in "
Views
" directory of your project (notice it is not the main web.config in project's root), find this section:you can add your custom namespace like this:
that will add the namespace to all of .cshtml (and/or .vbhtml) files; also you can change views inheritance from here, like:
Regards.
UPDATE: Thanks to @
Nick Silberstein
to his reminder about areas! He said:If you're working within an area, you must add the
namespace
within theWeb.config
under/Areas/<AreaName>/Views/
rather than/Views/
You can try this
I think in order import namespace in razor view, you just need to add below way:
For namespace and Library
For Model
For Iterate the list on Razor Page (You Have to use foreach loop for access the list items)