How to configure the ActionLink format to delete a subdirectory?

Say the domain that appears in my hosting root directory is example.com. GoDaddy creates a mapping of other domains to root subdirectories. For example, my second domain example1.commaps to example.com/example1.

I loaded my ASP.NET MVC site into such a subdirectory, only to find that the ActionLinks for navigation are in the following format:

http://example1.com/example1/Controller/Action

In other words, even when I use a domain that appears in a subdirectory, the subdirectory is still used in the URL. I want to change the format of my ActionLinks.

However, I noticed that I can also access the same path by going to:

http://example1.com/Controller/Action

(excluding subdirectory)

I want my ActionLinks to automatically drop out of the subdirectory, as this is not required.

, ActionLinks URL?

+3
2

, , , /. , , URL, iirf.codeplex.com, . , , , .

.

+1

global.asax, . :

routes.AddRoute("example1/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.AddRoute("{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

, asax, . "example1" URL-.

+1

Source: https://habr.com/ru/post/1749272/


All Articles