code

Web Api: custom binding with AutoMapper

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

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…

code

MVC custom error pages

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

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.

code

MVC parameter binding

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

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.

code

Because empty tags are bad

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

Well, not always, but there are times when they are so…what can I do to avoid them.

code

MVC custom validator with client side validation

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

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.

code

MVC Greedy route mapping and custom route handler

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

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.

web

Default route with areas in asp.net MVC

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

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.