Tag: ASP.NET

  • 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 use the Unit of Work pattern with Unity 2.0

    Update 2013-04-18 I’ve updated the EndRequest event handler to only commit the changes if no error occurred in the current HTTP request. In one of my last post, I showed how to set up the Unity 2.0 dependency injection container in an ASP.NET MVC 3 web application. In this post, I will show how to […]

  • 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 […]

  • ASP.NET MVC 3: How to get the current controller and action in a Razor view

    The following code snippet enables you to access the name of the controller and the action that are processing the (current) request: Controller: @ViewContext.Controller.ValueProvider.GetValue(“controller”).RawValue View: @ViewContext.Controller.ValueProvider.GetValue(“action”).RawValue

  • Microsoft Visual Studio & ASP.NET MVC 3: Add jQuery IntelliSense support for Razor pages

    To enable Visual Studio’s IntelliSense support for jQuery on Razor pages just add the following code line to your view: @if (false) { } Note: The if-statement prevents the script tag from being rendered into the html source code. Unfortunately, with the Razor view engine, there is no central place to add the reference to […]