Tag: MVC 3

  • ASP.NET MVC3: Controller extension methods to render a partial view to string

    To handle AJAX form requests in my ASP.NET MVC3 controller I needed a way to render a partial view to a string to return a JSON result containing both the (server-side) validation result (as boolean) and a rendered partial view (as string). Unfortunately in ASP.NET MVC3 there seems no out-of-the-box support for rendering partial views […]

  • ASP.NET MVC: Fix IControllerFactory implementation after upgrading from MVC 2 to MVC 3

    Recently, I upgraded an ASP.NET MVC 2 application to ASP.NET MVC 3. I used the ASP.NET MVC 3 Application Upgrader tool (see this blog post for more information) which enables you to upgrade an existing MVC 2 project automatically. After the upgrade process I got an compile error in my custom controller factory, because the […]

  • ASP.NET MVC: How to add ELMAH (Error Logging Modules and Handlers for ASP.NET)

    In this tutorial, you will find a step by step instruction how to add ELMAH (Error Logging Modules and Handlers for ASP.NET) to your existing ASP.NET MVC application. ELMAH is an easy-to-plug in library that logs and reports unhandled exceptions in ASP.NET application. It is described as follows: ELMAH (Error Logging Modules and Handlers) is […]

  • ASP.NET: Prevent IIS 7.5 from overriding custom error pages with IIS default error pages

    I’ve created a ASP.NET MVC 3 application with custom error pages for HTTP status code 404 (“Not Found”) and 500 (“Internal Server Error”). I registered my custom pages in the Web.config as follows: After deploying my ASP.NET application to an IIS 7.5 web server I was surprised by the fact that the IIS web server […]

  • ASP.NET MVC 3: How to stream files to clients

    Streaming files to the client is very easy using ASP.NET MVC 3: The following code snippet shows an exemplary controller action “Download” that streams data to the client. If the client requests this action (e.g. by using the link [YOUR_CONTROLLER]/Download) the browser will (depending on it’s settings) start downloading the data or open the download […]

  • ASP.NET MVC 3: Dependency injection with Unity 2.0

    Update 2011-07-03: I’ve written a new blog post “ASP.NET MVC 3 & Unity 2.0: Using XML configuration for design-time configuration” that shows how to use XML configuration to set up the Unity dependency injection container. Update 2011-03-28: I’ve fixed an error in the Application_Start method and added a sample Visual Studio 2010 project that includes […]