How to configure Microsoft.AspNet.FriendlyUrls

App_code>start>RouteConfig.vb

[vb]
Imports Microsoft.VisualBasic
Imports System.Web.Routing
Imports Microsoft.AspNet.FriendlyUrls

Public Class RouteConfig
Public Shared Sub RegisterRoutes(routes As RouteCollection)
Dim settings = New FriendlyUrlSettings()
settings.AutoRedirectMode = RedirectMode.Permanent
routes.EnableFriendlyUrls(settings)
End Sub
End Class
[/vb]

Global.asax

[text]
<%@ Import Namespace="System.Web.Routing" %>
[/text]

[vb]
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
‘Friendly URLs
RouteConfig.RegisterRoutes(RouteTable.Routes)
End Sub
[/vb]

Generate Friendly URLs without string concatenation

[html]

<a href="<%: FriendlyUrl.Href("~/Foo", "bar", 34) %>">Click me</a>

[/html]

if error on server:

[text]
Could not load file or assembly ‘Microsoft.Web.Infrastructure,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
or one of its dependencies. The system cannot find the file specified
[/text]

Run ASP.NET MVC 3 Tools Update
http://www.microsoft.com/en-us/download/confirmation.aspx?id=1491

related links:
http://www.hanselman.com/blog/CommentView.aspx?guid=724141DA-9E27-44AE-A370-9E311BAED472#73cdc003-407d-4d9a-8ea0-d397b5989cf4

http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx

Comments are closed.