Here is the solution I settled on. I installed the NuGet Microsoft.AspNet.FriendlyUrls package. Then I named the .aspx page with a page name that would look good without the extension. Then I set up the routing as follows:
public static void RegisterRoutes(RouteCollection routes)
{
FriendlyUrlSettings aspxSettings = new FriendlyUrlSettings();
aspxSettings.AutoRedirectMode = RedirectMode.Off; // default=Off
routes.EnableFriendlyUrls(aspxSettings);
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapPageRoute("Design-Fancy", "Design/Fancy/{*queryvalues}", "~/Design/Fancy.aspx", true);
routes.MapPageRoute("Design-Simple", "Design/Simple/{*queryvalues}", "~/Design/Simple.aspx", true);
}
时间: 2024-10-21 01:57:17