Sunday, February 21, 2010

URL Routing in ASP.NET 4.0

In ASP.NET MVC you can have clean nice SEO friendly Url.
For example:

However with ASP.NET 3.5 SP1, Webforms require an implementation of an IRouteHandler to support clean nice Url.
This can be quite tedious, and often require more work.

However with ASP.NET 4.0, you can add this support easily without having to use or implement an IRouteHandler.

The below two articles explain how to achieve this in web forms.

Happy Programming!

Saturday, October 3, 2009

Using C# 3.0 Anonymous Types as Dictionaries

public static string GetHtmlLink(string text, IDictionary properties)
//do some work

//too many lines and less efficient
Dictionary values = new Dictionary();
values.Add("key1", "value1");
values.Add("key2", "value2");
values.Add("key3", "value3");
GetHtmlLink("Click me", values);

MyParams myParams = new MyParams { Key1 = "value1", Key2 = "value2", Key3 = "value3" };
GetHtmlLink("Click me", myParams);

Sample link: <%= HtmlHelpers.GetHtmlLink("My Site", new { @class = "someStyle", href = "http://www
And it'll render this HTML:
Sample link: <a class="someStyle" href="">My Sitea>

<br />
Sample URL:'s+mittens&mode=details