How to configure Microsoft.AspNet.FriendlyUrls

App_code>start>RouteConfig.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

Global.asax

<%@ Import Namespace="System.Web.Routing" %>
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    'Friendly URLs
    RouteConfig.RegisterRoutes(RouteTable.Routes)
End Sub

Generate Friendly URLs without string concatenation


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

if error on server:

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

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

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *