Category: ASP.NET

  • MVC 3 Routing Example

    Below is an excerpt of a chapter from my new book: 20 Recipes for Programming MVC 3.

    In today’s heavily fought battles for search engine supremacy, it’s quite difficult to winthe race with a website address that looks like:

    http://www.example.com/books/details?id=4.

    Using routes, the website can look like:

    http://www.example.com/20-recipes-for-mvc3

    which provides much more context, both to the user and the search engine.

    (more…)

  • 20 Recipes for Programming MVC 3

    Yesterday marks the official launch of my second book: 20 Recipes for Programming MVC 3.  The book is being published by O’Reilly and is available in both e-book or print edition.  I’m quite proud of this book as I’ve feel like my writing style was really able to mature while working with a real editor to bring a great cookbook on ASP.NET’s MVC 3.

    The tagline for the book is, Faster, Smarter Web Development and that truly is my goal with all of the recipes in the book.  It covers basic material from authentication and emails to more complex features like routing and AJAX – even has an excellent tutorial on converting your website into a mobile site in a few easy steps!

  • ToLower-ToUpper and the CurrentCulture.CultureInfo

    I have recently being working on my largest multi-lingual site ever – over 30 languages – in ASP.NET.  While implementing it, there have been a lot of bumps and bruises along the way.  One of the most recent one was noticing that the ToUpper and ToLower functions in ASP.NET take the CurrentCulture.CultureInfo into consideration.

    As you may guess, this is both a blessing and a curse.

    When I’m working with text that is to be translated, but should appear upper or lower case this makes perfect sense that the CurrentCulture.CultureInfo should be taking into account.  However, be sure you remember this later when you are doing text transformations and text comparisons on words that should NOT be translated (like when using convert date with C#).

    At the end of the day, if you don’t want the CurrentCulture.CultureInfo to be used, both functions can be easily overloaded as follows:

    String.ToUpper(new CultureInfo(“en”))
    String.ToLower(new CultureInfo(“en”))

    I spent a fair bit of time tracking down why existing code was working perfectly, when suddenly as the team implemented the 8th language, something suddenly started failing.  Thank goodness for unit testing to quickly point out that there was a problem – then it was just a matter of understanding it!