{"id":1883,"date":"2014-07-14T16:49:52","date_gmt":"2014-07-14T16:49:52","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=1883"},"modified":"2016-09-30T14:11:29","modified_gmt":"2016-09-30T14:11:29","slug":"how-to-configure-microsoft-aspnet-friendlyurls","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=1883","title":{"rendered":"How to configure Microsoft.AspNet.FriendlyUrls"},"content":{"rendered":"<p>App_code&gt;start&gt;RouteConfig.vb<\/p>\n<p>[vb]<br \/>\nImports Microsoft.VisualBasic<br \/>\nImports System.Web.Routing<br \/>\nImports Microsoft.AspNet.FriendlyUrls<\/p>\n<p>Public Class RouteConfig<br \/>\n    Public Shared Sub RegisterRoutes(routes As RouteCollection)<br \/>\n        Dim settings = New FriendlyUrlSettings()<br \/>\n        settings.AutoRedirectMode = RedirectMode.Permanent<br \/>\n        routes.EnableFriendlyUrls(settings)<br \/>\n    End Sub<br \/>\nEnd Class<br \/>\n[\/vb]<\/p>\n<p>Global.asax<\/p>\n<p>[text]<br \/>\n&lt;%@ Import Namespace=&quot;System.Web.Routing&quot; %&gt;<br \/>\n[\/text]<\/p>\n<p>[vb]<br \/>\nSub Application_Start(ByVal sender As Object, ByVal e As EventArgs)<br \/>\n    &#8216;Friendly URLs<br \/>\n    RouteConfig.RegisterRoutes(RouteTable.Routes)<br \/>\nEnd Sub<br \/>\n[\/vb]<\/p>\n<p>Generate Friendly URLs without string concatenation<\/pre>\n<p>[html]<\/p>\n<p>&lt;a href=&quot;&lt;%: FriendlyUrl.Href(&quot;~\/Foo&quot;, &quot;bar&quot;, 34) %&gt;&quot;&gt;Click me&lt;\/a&gt;<\/p>\n<p>[\/html]<\/p>\n<p>if error on server:<\/p>\n<p>[text]<br \/>\nCould not load file or assembly &#8216;Microsoft.Web.Infrastructure,<br \/>\nVersion=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#8217;<br \/>\n or one of its dependencies. The system cannot find the file specified<br \/>\n[\/text]<\/p>\n<p>Run ASP.NET MVC 3 Tools Update<br \/>\n<a href=\"http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=1491\" target=\"_blank\">http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=1491<\/a><\/p>\n<p>related links:<br \/>\n<a href=\"http:\/\/www.hanselman.com\/blog\/CommentView.aspx?guid=724141DA-9E27-44AE-A370-9E311BAED472#73cdc003-407d-4d9a-8ea0-d397b5989cf4\" target=\"_blank\">http:\/\/www.hanselman.com\/blog\/CommentView.aspx?guid=724141DA-9E27-44AE-A370-9E311BAED472#73cdc003-407d-4d9a-8ea0-d397b5989cf4<\/a><\/p>\n<p><a href=\"http:\/\/www.hanselman.com\/blog\/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx\">http:\/\/www.hanselman.com\/blog\/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>App_code&gt;start&gt;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] &lt;%@ Import Namespace=&quot;System.Web.Routing&quot; %&gt; [\/text] [vb] Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) &#8216;Friendly URLs RouteConfig.RegisterRoutes(RouteTable.Routes) End Sub [\/vb] Generate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1883","post","type-post","status-publish","format-standard","hentry","category-truques-dicas","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1883"}],"version-history":[{"count":13,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1883\/revisions"}],"predecessor-version":[{"id":2037,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1883\/revisions\/2037"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1883"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}