Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 Areas how to use dashes in page names
    primarykey
    data
    text
    <p>We're using Areas with a project. And we're also using this fix to replaces dashes in page names</p> <pre><code> routes.Add( new Route("{controller}/{action}/{id}", new RouteValueDictionary( new { controller = "Home", action = "Index", id = UrlParameter.Optional }), new HyphenatedRouteHandler()) ); public class HyphenatedRouteHandler : MvcRouteHandler { protected override IHttpHandler GetHttpHandler(RequestContext requestContext) { requestContext.RouteData.Values["controller"] = requestContext.RouteData.Values["controller"].ToString().Replace("-", "_"); requestContext.RouteData.Values["action"] = requestContext.RouteData.Values["action"].ToString().Replace("-", "_"); return base.GetHttpHandler(requestContext); } } </code></pre> <p>This Fix works fine with the normal top level pages. Home/some-page. But when it comes to an Area this no longer works. I tried modifying the AreaRegistration.cs file to be an equivalent to the Global.asax.cs route but that didn't work either. I can rename the pages with [ActionName("some-page")] but it doesn't solve the problem of the controller still having underscores Area/some_folder/some-page and I don't want my URLs to look like that.</p> <p><strong>Edit:</strong> When I use the route that Darin Dimitrov suggest I get this error:</p> <p><em>Multiple types were found that match the controller named 'page'. This can happen if the route that services this request ('admin/{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.</em></p> <p>We have multiple "segments" that have the same names but different content to target the segment audience</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload