views:

94

answers:

2

Hi,

How would you accomplish these in ASP.NET Webforms 4.0 Routing;

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

Thanks.

+1  A: 

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

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");
}

Adding parameters as necessary

David
Yeah, but it doesn't prevent to reach default.aspx directly and also start page remains as default.aspx.
Alper Ozcetin
A: 

You can specify ignore routes to ignore routing for your static handlers, for the static content part (though routing, if the static file exists, normally gets routed directly to the file no problem).

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

Brian