-
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 […]
-
WordPress: Add AJAX functionality to comment form with WP-Ajaxify-Comments plugin
Update 2014-11-27: WP-Ajaxify-Comments is now supported by weweave, see project homepage for more details. When submitting the comment form, WordPress by default reloads the complete page. In case of an error (e.g. an invalid e-mail address or an empty comment field) the error message is shown on top of a new (blank) screen and the […]
-
WordPress & jQuery: Fix JavaScript error “$ is not a function”
When using jQuery in WordPress you might be surprised by a $ is not a function JavaScript error. For example, in a default WordPress 3.3.1 installation, the following JavaScript code leads to this error: $(document).ready(function() { console.log($(“body”)); }); The reason is, that WordPress by default uses jQuery’s “no conflict mode” to avoid compatibility problems with […]
-
ASP.NET How-To: Create User Control library by compiling User Controls into .dll files
This blog post shows how to create a User Control library (a .dll file containing User Controls). To reuse the contained User Controls in other ASP.NET web projects you just need to add a reference to this .dll file and register a tag prefix (as shown at the end of this post). First, we need […]