-
ASP.NET MVC 4 RC: Get current controller name from HttpContext
To find out the name of the current controller from a HTTP context, you can use the following code snippet: var controllerName = RouteTable.Routes.GetRouteData( new HttpContextWrapper(HttpContext.Current) ).Values[“controller”].ToString();
-
ASP.NET MVC 4 RC & ASP.NET Web API: Implementing custom XmlMediaTypeFormatter that ignores XML namespaces
In this blog post I will show how to implement a custom XmlMediaTypeFormatter that extends the default ASP.NET Web API XmlMediaTypeFormatter in a way that it ignores XML namespaces when parsing xml messages. By default the ASP.NET Web API XmlMediaTypeFormatter is not able to parse XML requests that contain any XML namespace declarations. If you […]
-
ASP.NET MVC 4 RC & ASP.NET Web API: Return “HTTP Status code 4xx” instead of throwing InvalidOperationException “No MediaTypeFormatter is available to read an object of type ‘[…]’ from content with media type ‘[…]’”
By default ASP.NET Web API (included in ASP.NET MVC 4) throws the following exception when trying to process a request with an unsupported content-type (like “text/plain”): System.InvalidOperationException No MediaTypeFormatter is available to read an object of type ‘[…]’ from content with media type ‘[…]’. IMHO, sending a wrong content-type is a client-side error, and the […]
-
ASP.NET MVC 3 & MongoDB: CRUD operations in NoSQL database using FluentMongo
This blog post shows how to use the open-source NoSQL database MongoDB in an ASP.NET MVC 3 web application. The showcase web application uses FluentMongo that adds LINQ-support for the 10gen MongoDB C# driver. Summarized the application demonstrates how to perform the basic CRUD (create, read, update and delete) database operations. Before running the example […]
-
ASP.NET MVC 3: Validate complex Types (Objects & Lists) in Ajax Form using jQuery and JSON on Client Side and Server Side
This blog post shows how to validate models containing complex types such as Objects and Lists in ASP.NET MVC 3. We start with the source code described in one of my previous posts “ASP.NET MVC 3: Using JSON result for jQuery Ajax Forms validation” (you can download the Visual Studio 2010 project here). Summarized this […]
-
ASP.NET MVC 3: Use re-mix library to add controller actions with mixins – Part 2
This is an update to my previous post “ASP.NET MVC 3: Use re-mix library to add controller actions with mixins”. In November last year I implemented a prototypical approach that uses mixins to add actions to ASP.NET MVC 3 controllers. Since .NET does not support the mixin concept out of the box, I used the […]