I’ve been working on a few ASP.NET MVC demos recently, one of which uses a custom ActionResult to send an iCal file back to the user. As part of the custom ActionResult I add a Content-Disposition header to the reply so the user is prompted to download the file.
When I went to test the code in the browser however (Ctrl+F5), I received a “This operation requires IIS integrated pipeline mode” exception. What makes this particularly interesting is that I am not running in IIS, but rather the out-of-the-box ASP.NET Development Server that comes with Visual Studio so I don’t have control over the “pipeline mode”. Initially searching didn’t turn up anything helpful either.
It turns out that the answer is really quick and easy; simply change:
response.Headers.Add(…)
to
response.AddHeader(…)