Routing to a virtual item

I am trying to create a route in a route table that is routed to a virtual item (using cms, which creates a url like example.com/about/company, where there is no physical file called the company exists) using system.web. (unfortunately, I cannot use iis rewriting / routing). I tried the following, but this leads to 404. If I were to point to another physical file (test target), routing works fine.

void RegisterRoutes(RouteCollection routes)
{
    routes.RouteExistingFiles = true;
    routes.MapPageRoute("about", "about/us", "~/about/company", false);
}

So, is it possible to specify such an element?

+5
source share
3 answers

, , Sitecore, , , , .

- MVC webforms. , , , , .

https://github.com/Sitecore/Sitecore-Mvc-Routing

+1

MapPageRoute. MapPageRoute , PageRouteHandler. PageRouteHandler Class :

PageRouteHandler Route URL- . PageRouteHandler , URL.

MVC, RouteCollectionExtensions. MapRoute MvcRouteHandler :

routes.MapRoute("about", "about/us", new { controller = "about", action="company", id="" });

, . , (#), , MVC .

MVC, , UrlRoutingHandler Class RouteCollection.

+1

, /content/something, IIS. , , , 404 URL-. , 404 .

, RouteExistingFiles . , . RouteExistingFiles = true, , . , , , , , ? .

, MapPageRoute . , Microsoft : http://msdn.microsoft.com/en-us/library/dd329551.aspx

routes.MapPageRoute("SalesRoute",
    "SalesReport/{locale}/{year}",
    "~/sales.aspx");

This will cause the corresponding routes to call sales.aspxin response. In your example, the target ~/about/company, which looks like a route, and not the actual target — your actual target, which processes the CMS request, should have an extension aspx.

+1
source

All Articles