• Products

    Microsoft .NET

    Microsoft .NET components, libraries & tools

    • EmailVerify for .NET
      Email validation library, featuring full IETF-compliant syntax validation, DNS checking, mailbox existence test and tools for advanced batch processing.
    • ProxyClient for .NET
      Powerful proxy client library with support for SOCKS 4, SOCKS 4a, SOCKS 5 and HTTP proxy servers, allowing to establish and accept remotely proxied connections.
    • MVC Extensions
      Powerful routing engine extensions for ASP.NET: allows to declare routes by way of attributes applied to MVC actions and generates URLs using compiler-safe lambda expressions.

    Microsoft Silverlight

    Microsoft Silverlight components, libraries & tools

    • EmailVerify for Silverlight
      Email validation library with Data Annotations support, featuring advanced syntax verification, ISP-specific syntax checks and disposable email address handling.

    Microsoft Visual Studio extensions

    Development tools, integrated into your favorite IDE

    • Routing Assistant
      FREE

      A cool and free Visual Studio extension which allows to easily browse, define, match and filter ASP.NET MVC routes within ASP.NET applications and web sites.

  • Purchase

    Products

    • EmailVerify for .NET
      • Licensing / editions
      • Volume discounts
      • Upgrades
      Purchase
    • ProxyClient for .NET
      • Licensing
      • Volume discounts
      • Upgrades
      Purchase
    • MVC Extensions
      • Licensing
      • Volume discounts
      • Upgrades
      Purchase

    Request a quote

    • Contact us
      Send a request to our sales staff.

  • Support

    Knowledge base

    • Browse the knowledge base
      Support documents for our products and services.

    Request support

    • Contact us
      Send a request to our customer support staff.

  • About us

    About Cobisi

    About our company, our team, our mission

    • Our company
      Cobisi company information.
    • Our mission
      About what we aim to achieve.
    • Follow us
      Follow us on Twitter.

    Contact us

    • Contact us
      Send a request to our customer support staff.

  • Company blog

    Latest posts from our blog

    Shared thoughts about our technologies, products and services

    • Routing Assistant reached version 1.7
      Published on Thursday, March 21, 2013

    • Verifalia: a new, complete hosted email validation service
      Published on Thursday, December 6, 2012

    • Routing Assistant v1.4 released
      Published on Friday, October 12, 2012

MVC Extensions

An awesome routing engine for ASP.NET MVC 3 and 4

  • Overview
  • Tutorial
  • Release notes
  • Free edition
  • Licensing
  • Purchase

🤖
MVC Extensions has been discontinued, sorry
We have discontinued this product because newer ASP.NET versions already include a similar attribute-based routing mechanism.

Using enumeration parameters

From a SEO point of view, one of the top concerns of passing enumerated values (System.Enum instances) to MVC action methods has always been that routed enum values must match their enum fields names. This means that, in traditional ASP.NET MVC, a route that accepts enum values will have the underlying enum fields names in the URL itself, leading to potential ugly URLs and bad search engine ranking.
In traditional ASP.NET MVC, for example, the following
Foo
action would be reached using either
~/foo/FirstUglyValue
or
~/foo/SecondUglyValue
and this behavior can't be changed:

Excerpt from the controller class:
            public enum MyEnum
            {
                FirstUglyValue,
                SecondUglyValue
            }

            public class MyController : Controller
            {
                public ActionResult Foo(MyEnum bar)
                {
                    return Content("Baz!");
                }
            }
        

Excerpt from the application class (global.asax.cs):
        public static void RegisterRoutes(RouteCollection routes)
        {
            // ...

            routes.MapRoute("MyUglyRoute",
                "{action}/{bar}",
                new {
                        controller = "MyController",
                    });

            // ...
        }
        

SEO Extensions takes a different approach and allows to easily map each enumerated value to a specific string, giving ASP.NET developers the full power to control how their routes are built and handled. In fact, you can easily control the URL segment of your enum values by decorating with the
EnumUrl
attribute the fields you wish to map, along with the URL segment itself.
To do that, the aforementioned route needs to be converted to a SEO route (remember, explicit route mapping in your application class is not needed anymore with this technique, as SEO Extensions automatically takes care of the routes registration on your behalf) and the enum needs a small revision to include the
EnumUrl
attribute:
            public enum MyEnum
            {
                [EnumUrl("first")]
                FirstUglyValue,

                [EnumUrl("second")]
                SecondUglyValue
            }

            public class MyController : Controller
            {
                [Route.Action("~/foo")]
                public ActionResult Foo([Route.Param] MyEnum bar)
                {
                    return Content("Baz!");
                }
            }
        

This way, the action shown above would be automatically reached by using either
~/foo/first
or
~/foo/second
, possibly with a much higher SEO ranking.


Handling unmodifiable enums

What if you don't have access to the enum source code? SEO Extensions includes a handy class named
EnumUrlMapperRegistry
which allows to easily define application-wide mappers for your enumerations, by way of implementations of the
IEnumUrlMapper
interface. The usage is very simple, as the
IEnumUrlMapper
interface has just two methods:
MapFieldNameToUrl()
and
MapUrlToFieldName()
, which do exactly what their names suggest. Furthermore, SEO Extensions comes with a useful
IEnumUrlMapper
implementation named
DictionaryEnumUrlMapper
that allows bidirectional links between URLs and field names (something you may wish most of the times).
Following the previous example and now supposing the
MyEnum
has been defined in assembly you can't modify to add the
EnumUrl
attributes, the next example shows how you would obtain the same results while adding an enum mapper to the
EnumUrlMapperRegistry
and leaving the action as it was:

Excerpt from the controller class (same as above):
            public class MyController : Controller
            {
                [Route.Action("~/foo")]
                public ActionResult Foo([Route.Param] MyEnum bar)
                {
                    return Content("Baz!");
                }
            }
        

Excerpt from the application class (global.asax.cs):
        public static void RegisterRoutes(RouteCollection routes)
        {
            // ...

            var coolMapper = new DictionaryEnumUrlMapper<MyEnum>();
            
            coolMapper.Map(MyEnum.FirstUglyValue, "first")
            coolMapper.Map(MyEnum.SecondUglyValue, "second")

            EnumUrlMapperRegistry.Register(typeof(MyEnum), coolMapper);

            // ...
        }
        


Content


  • Introduction
  • Installation
  • Your first SEO (declarative) route
    • Application (Global.asax) setup
    • Visual feedback in the IDE
  • Handling parameters
    • Visual feedback in the IDE
    • Validation
    • Built-in constraints
    • Enumerated values
      • Handling unmodifiable enums
  • Getting URLs from routes
    • Redirecting to SEO (declarative) routes
  • Views
    • Root namespace prefix


Not what you are looking for?


Please don't hesitate to contact us with your questions and comments; technical support is always free of charge, and requests made by registered clients will have higher priority.
Products
  • EmailVerify for .NET
    • Features
    • Online demo
    • Download
    • Licensing / editions
    • Release notes
    • Purchase
  • ProxyClient for .NET
    • Download
    • Licensing / editions
    • Release notes
    • Purchase
  • MVC Extensions
    • Tutorial
    • Free edition download
    • Licensing
    • Release notes
    • Purchase
Support
  • Knowledge base
  • Request support

About Cobisi
  • The company
  • Mission
  • Follow us
  • Contact us
Copyright © 2005-2022 Cobisi Research. All rights reserved.
Cobisi Research - Via Della Costituzione, 31 - 35010, Vigonza - Italy (European Union)
VAT ID: IT04391160282