ASP.NET Webforms 4.0 Routing: How to Get Rid of Physical URLs

How would you do in ASP.NET Webforms 4.0 routing,

  • .aspx pages should not be accessible directly, pages should only be accessible with routes,
  • The start page should be "/" or "/ home" or something else, but not "Default.aspx".

Thanks.

+7
webforms routing
source share
2 answers

You can specify ignore routes to ignore routing for your static handlers, for some of the static content (although routing, if there is a static file, is usually routed directly to the file without problems).

I believe the method you want to use is MapPageRoute for web forms, which is for web forms. See Examples: http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.mappageroute%28VS.100%29.aspx

+1
source share

Have you read Scott Guthrie's post introducing this topic?

http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series. aspx

You would do the following:

void RegisterRoutes(RouteCollection routes) { routes.MapRoute("nameofroute", "home/", "~/Default.aspx"); } 

Add options as needed

0
source share

All Articles