I am making an ASP.NET MVC application with the razor engine.
And I was wondering if it's possible to use Regions in a view.
something like:
#region blabla <p>@Model.Name</p> <p>...</p> #endregion
This does not work. Is there an alternative?
html or . cshtml code editor, type region , then press Tab key.
Area allows us to partition the large application into smaller units where each unit contains a separate MVC folder structure, same as the default MVC folder structure. For example, a large enterprise application may have different modules like admin, finance, HR, marketing, etc.
Areas are an ASP.NET feature used to organize related functionality into a group as a separate namespace (for routing) and folder structure (for views). Using areas creates a hierarchy for the purpose of routing by adding another route parameter, area , to controller and action or a Razor Page page .
Right click the Views\HelloWorld folder and click Add, then click MVC 5 View Page with Layout (Razor). In the Specify Name for Item dialog box, enter Index, and then click OK. In the Select a Layout Page dialog, accept the default _Layout. cshtml and click OK.
This works in Visual Studio 2015 and above (thanks to @dotnetN00b
for the sample in the comments section):
<!-- #region Test --> code here <!-- #endregion -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With