I'm using asp.net MVC 3 for my website , I want to replace underlines with dashes in my addresses . I can do it . but when I want to replace them inside a area I can't do it .
who can help me ?
this is my code :
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);
}
}
and this is my area route :
context.MapRoute(
"products_default",
"products/{controller}/{action}",
new { controller = "All", action = "Index" }
);
I want to navigate this address :
localhost:1559/products/store-builder/boronz
product is my area name . of course when I navigate this address :
localhost:1559/products/store_builder/boronz
it shows page .
EDIT :
I use this for my area route but it can't detect this is an area :
//context.Routes.Add(
// new Route("products/{controller}/{action}",
// new RouteValueDictionary(
// new { controller = "", action = "Index" }),
// new MyProject.MvcApplication.HyphenatedRouteHandler())
//);
how can I fix this ?