Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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 to anyone who can help!
Posted
Comments
TryAndSucceed 8-Oct-13 10:46am    
Can you explain this line,please? "My problem is that it does this for all the pages (i.e., .com/Account/Login.aspx."
Jack R. Schaible 8-Oct-13 10:48am    
It's supposed to route pages that have no file extension; but instead it's routing all pages that follow that format.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900