FriendlyUrls – For ASP.NET WebForms
FriendlyUrls is a new ASP.NET feature that allows developers to easily use pretty urls in their web forms applications. It also makes it easier to manage both Mobile and Desktop views in the same project, similar to MVC. Scott Hanselman explains more.
How do you use this package? Just add the nuget package to the project, call routes.EnableFriendlyUrls() and your /Foo.aspx will be available at the /Foo route! You can also use Url segments to pass more information to the page (/Foo/bar/34) and then retrieve it using Request.GetFriendlyUrlSegments() method for use in the Foo.aspx page.
Some more exciting features Scott shows -
- Automatic switching to mobile-specific views if the request comes from a mobile device
- Ability to customize behaviour by extending the WebFormsFriendlyResolver class – for e.g. to add device-specific handling
Scott emphasizes how this is just one more step in the grand One ASP.NET plan that is getting evolved over time. We have already noted how the productivity gap between Web Forms and MVC is getting reduced with the .NET 4.5 release.
Note that FriendlyUrls is still in alpha, mainly out to elicit more feedback from developers. It does however work with both .NET 4.5 and .NET 4.0, so you can use it with your existing .NET 4 applications as well.