I have a route config file that I'm trying to route all URLs that follow the formula .com/{a page}/{a subpage}, to route to a specific page .com/Default/Page.aspx. My problem is that it does this for all the pages (i.e., .com/Account/Login.aspx. Is there a way to specify that I want it to route to that page only when a user types it into the address bar, possible only when they leave out the .aspx extension? This is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.Membership.OpenAuth;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;
namespace CouponsForGiving
{
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("LearnMore", "LearnMore", "~/LearnMore.aspx");
routes.MapPageRoute("DefaultPage", "{nponame}", "~/Default/NPOPage.aspx");
routes.MapPageRoute("CampaignPage", "{nponame}/{campaignname}", "~/Default/CampaignPage.aspx"); //This one routes a lot of other pages
routes.EnableFriendlyUrls();
}
}
}
Thanks!