How to install Microsoft.AspNet.FriendlyUrls
Learn more and find how to install the newly launched ASP.NET feature FriendlyUrls which allows you to create friendly URLs for your ASP.NET web applications without going through the hassles involved in Url rewriting.
Scott Hanselman's blog post about ASP.NET FriendlyUrls is an exciting news for all ASP.NET developers. Microsoft.AspNet.FriendlyUrls extension allows you to access your .ASPX pages without using the .ASPX extension. All you have to do is, install the new extension on your Visual Studio using Extension Manager and add a single line of code in to your Global.aspx file. Once the extension is references in your project and the code is added, you can access any of the .aspx pages in your website without using the .aspx file extension.
For example, if you have a webpage /resources/7360-How-install-Microsoft.AspNet.FriendlyUrls.aspx, you will be able to access it using the url /resources/7360-How-install-Microsoft.AspNet.FriendlyUrls
Isn't the url looking better and simpler without the file extension?How to install and reference Microsoft.AspNet.FriendlyUrls extension
Right click on the "References" in the web application project. Select "Manage NuGet Packages".
Now you can see the NuGet Package Manager. Click on "Online" on the left side to see the online packages. In the middle window, select "Include Prerelease" so that it will display all prerelease software also. (The Microsoft.AspNet.FriendlyUrls package is current on Alpha release and so you need to choose this option to see it in the list).
You may see a lot of packages in the list. If you are unable to find the Microsoft.AspNet.FriendlyUrls package in the list, you may search for it. Look for the search window on the top right corner. Type "AspNet.FriendlyUrls" and press Enter. It will show the package Microsoft.AspNet.FriendlyUrls. Click on the "Install" button to install this extension for your Visual Studio.
In the next step, you will be asked to accept the license terms. Click on the "I Accept" to accept the license terms and proceed with the installation of the extension.
The installation will complete within few seconds. One thing to be noted that you will not get any confirmation dialog that says installation is completed. All you will see that the install button will disappear from the NuGet Manager and you will see a small green color check mark that indicates the installation is complete.
After the installation of the Microsoft.AspNet.FriendlyUrls extension, you will see a new file automatically added to your Visual Studio project with the name "packages.config". This file will have the following content:<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.FriendlyUrls" version="1.0.0-alpha1" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
</packages>
You are almost done. Now, the only work remaining for you is to add a single line of code to your Global.asax file to use the newly installed extension. Open your Global.asax file. Add "RouteConfig.RegisterRoutes(RouteTable.Routes);" in the Application_Startup event as shown below:
void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
Add a reference at the top of the Global.asax file as shown below:using System.Web.Routing;
You are all set. Now you can access your web pages without using the .aspx file extension. All requests to the urls without the .aspx extension will be redirected to the corresponding .aspx pages.
Folder name conflict
If the file name without the .aspx extension matches a folder name under the same parent folder, you will have a conflict. The prerelease version of this extension prefers the folder name in such a case on my development computer, which runs Windows 7 and Visual Studio 2010.
/resources/7360-How-install-Microsoft-AspNet-FriendlyUrls.aspx
It appears to me this is resolved by some.aspx?id=7630
but really don't know how.
Thanks...