F9 Group Marketing and Technology Blog

Marketing, Technology, and current news at http://www.f9group.com/

Entries Tagged ‘categoryname’

URL Routing in ASP.NET 4.0

In the .NET Framework 3.5 SP1, Microsoft introduced ASP.NET Routing, which decouples the URL of a resource from the physical file on the web server. With ASP.NET Routing you, the developer, define routing rules map route patterns to a class that generates the content. For example, you might indicate that the URL Categories/ CategoryName maps to a class that takes the CategoryName and generates HTML that lists that category’s products in a grid. With such a mapping, users could view products for the Beverages category by visiting www.yoursite.com/Categories/Beverages . In .NET 3.5 SP1, ASP.NET Routing was primarily designed for ASP.NET MVC applications, although as discussed in Using ASP.NET Routing Without ASP.NET MVC it is possible to implement ASP.NET Routing in a Web Forms application, as well. However, implementing ASP.NET Routing in a Web Forms application involves a bit of seemingly excessive legwork. In a Web Forms scenario we typically want to map a routing pattern to an actual ASP.NET page. To do so we need to create a route handler class that is invoked when the routing URL is requested and, in a sense, dispatches the request to the appropriate ASP.NET page

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

Using ASP.NET Routing Without ASP.NET MVC

ASP.NET MVC is a Microsoft-supported framework for creating ASP.NET applications using a M odel- V iew- C ontroller pattern. In a nutshell, ASP.NET MVC allows developers much finer control over the markup rendered by their web pages, a greater and clearer separation of concerns , better testability, and cleaner, more SEO -friendly URLs. This article is not about ASP.NET MVC, but rather focuses on ASP.NET Routing, which is the technology by ASP.NET MVC to allow for intuitive and “hackable” URLs . There is typically a one-to-one correspondence between the files on the website and the URLs through which visitors interface with the site. For instance, if you worked for an eCommerce company and were tasked with creating a web page that displayed a list of products for a particular category you’d likely create a new page – say, ShowProductsByCategory.aspx – and add markup and code so that it displays the products for the category specified via the querystring. Once deployed to a production environment, visitors would reach this page via the URL www. yoursite .com/ShowProductsByCategory.aspx?CategoryID= categoryID and would see the products for the category categoryID .

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz