I'm starting a new webforms project using Microsoft.AspNet.FriendlyUrls but want to be able to set a default route for a folder. I have a folder called news which contains news.aspx and newsitem.aspx. I'd like to be able to route as follows:
http://sitename/news - Routes to ~/news/news.aspx
http://sitename/news/news - Routes to ~/news/news.aspx
http://sitename/news/newsitem - Routes to ~/news/newsitem.aspx
The second and third routes work using the code below but not http://sitename/news
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
routes.MapPageRoute("NewsDefault", "news", "~/news/news.aspx");
}
}
Found Solution
Needed to add
routes.RouteExistingFiles = true;