Web Api: custom binding with AutoMapper

In Web Api 2.0 and MVC5 you can only pass: int, bool, double etc.., TimeSpan, DateTime, Guid, decimal, and string values in URI. For any complex type having lists or other complex object within you have to pass serialized JSON/XML in the request body. But what If we want use such complex type from URI? Then read on…

By Piotr on (tags: automapper, mvc, Web API, categories: code)

MVC custom error pages

Long story short – mvc does not handle custom error pages in a way that could be described as ‘even close to correct’. But if you need to fulfill a requirement, you start hacking.

By on (tags: mvc, categories: code, web)

MVC parameter binding

Here’s a piece of information that will hopefully save you the time I spent on trying to figure it out… asp.net mvc parameter binding is localizable ONLY in the case of POST form action.

By on (tags: mvc, categories: code)

MVC custom validator with client side validation

I wanted to have a reusable email validator since there have been a few cases already where I needed one. Previously I just used the RegularExpressionAttribute but that’s verbose for email. So, without thinking much, I created an attribute that derived from RegularExpressionAttribute and supplied it with a regex I used – that turned out to be a surprise.

By on (tags: mvc, categories: code)

MVC Greedy route mapping and custom route handler

I’m learning to love MVC mostly for it’s flexibility. In a recent situation, I wanted to have a generic controller that will perform CRUD (Create Read Update Delete) operations on an entity. By default, this is not handled, but with a little custom code, it turned out to be quite easy.

By on (tags: mvc, categories: code)

Default route with areas in asp.net MVC

I stumbled upon a problem when trying to set up a default route for an asp.net mvc3 application. The routing mechanism itself is pretty straightforward, so I didn’t really expect any problems here, but as it turned out I was wrong.

By on (tags: area, mvc, route, categories: web)