{"id":882,"date":"2018-06-01T08:07:46","date_gmt":"2018-06-01T08:07:46","guid":{"rendered":"http:\/\/www.netexl.com\/blog\/?p=882"},"modified":"2026-04-02T09:55:51","modified_gmt":"2026-04-02T09:55:51","slug":"add-seo-friendly-urls-to-asp-net-application","status":"publish","type":"post","link":"https:\/\/www.netexl.com\/blog\/add-seo-friendly-urls-to-asp-net-application\/","title":{"rendered":"Add SEO Friendly URL&#8217;s to ASP.NET Application"},"content":{"rendered":"<p>It&#8217;s very important for a web site to create SEO friendly URL&#8217;s and remove page extensions such as .aspx. When search engines look at a site, the first thing they analyze is the page URL which help them ascertain what the page content is about.<\/p>\n<p>In ASP.NET application Routes can be used for this\u00a0which are URL patterns used for processing requests and can be used to construct URLs dynamically.\u00a0The Global.asax file is a special file that contains event handlers for\u00a0<em>ASP<\/em>.<em>NET<\/em>\u00a0application lifecycle events. The\u00a0<em>route table<\/em>\u00a0is created during the Application Start event in Global.asax.<\/p>\n<p>In order to do so add Global Application Class (Global.asax) to your ASP.NET Web Application if it is not created yet.<\/p>\n<p>The following example shows how to add a route.<\/p>\n<pre class=\"lang:default mark:19 decode:true\">protected void Application_Start(object sender, EventArgs e)\r\n{\r\n    try\r\n    {\r\n        RegisterRoutes(RouteTable.Routes);\r\n    }\r\n    catch (Exception ex)\r\n    {\r\n        \/\/ Log Exception here\r\n    }\r\n}\r\n\r\nprotected static void RegisterRoutes(RouteCollection routes)\r\n{\r\n    if (routes != null)\r\n    {\r\n        RouteTable.Routes.Add(new Route(\"{resource}.axd\/{*pathInfo}\", new StopRoutingHandler()));\r\n\r\n        routes.MapPageRoute(\"DefaultRoute\", \"\", \"~\/Default.aspx\");\r\n        routes.MapPageRoute(\"SomePage\", \"somepage\", \"~\/SomePage.aspx\");\r\n\r\n    }\r\n}\r\n<\/pre>\n<p>The marked line adds a route for default landing page of the web site so a website URL such as http:\/\/somewebsite.com\/Default.aspx will be changed to http:\/\/somewebsite.com.<\/p>\n<p>Similarly\u00a0http:\/\/somewebsite.com\/SomePage.aspx will be changed to http:\/\/somewebsite.com\/somepage in the example which is a lot better now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s very important for a web site to create SEO friendly URL&#8217;s and remove page extensions such as .aspx. When search engines look at a site, the first thing they analyze is the page URL which help them ascertain what the page content is about. In ASP.NET application Routes can be used for this\u00a0which are URL patterns used for processing requests and can be used to construct URLs dynamically.\u00a0The Global.asax file is a special file that contains event handlers for\u00a0ASP.NET\u00a0application lifecycle events. The\u00a0route table\u00a0is created during the Application Start event in Global.asax. In order to do so add Global Application Class (Global.asax) to your ASP.NET Web Application if it is not created yet. The following example shows how to add a route. protected void Application_Start(object sender, EventArgs e) { try { RegisterRoutes(RouteTable.Routes); } catch (Exception ex) { \/\/ Log Exception here } } protected static void RegisterRoutes(RouteCollection routes) { if[&#8230;]<\/p>\n","protected":false},"author":5,"featured_media":1540,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,14],"tags":[],"class_list":["post-882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","category-how-to"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/comments?post=882"}],"version-history":[{"count":2,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/882\/revisions"}],"predecessor-version":[{"id":884,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/882\/revisions\/884"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media\/1540"}],"wp:attachment":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media?parent=882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/categories?post=882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/tags?post=882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}