I’m writting a UrlHelper and now I need to write a nested function because for example I have page Articles which is accessed for everyone and I have separate Articles in Admin panel.
First have link: /Articles and next /Admin/Articles.
So I want to use UrlHelper like this:
In public page:
Url.Articles()
In admin page:
Url.Admin.Article()
Please tell me how I can achieve it?
You can implement
Url.Admin().Article()by writing anAdmin()extension method for the UrlHelper that returns an instance of some class with the Article() method.However, C# does not support extension properties so the
Url.Admin.Article()nested method is not possible without modifying ASP MVC source code.