English 中文(简体)
Visual Studio 2008 built-in web server needs integrated pipeline mode for Adding Http Header
原标题:

Using Visual Studio 2008 and built-in web server.

In a Web Handler .ashx file

    public void ProcessRequest(HttpContext context) {

        context.Response.ContentType = MimeType_text_xvcard;
        context.Response.Headers.Add(HttpHeader_ContentLength, "2138");

when I try to add an HTTP header I get the exception:

This operation requires IIS integrated pipeline mode.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.

I can find information about this error on the Internet but need specific info about how to presumably enable Integrated Pipeline mode (through web.config?) to allow HTTP headers to be manipulated.

How do do I put the built-in web server into integrated pipeline mode? Note: Not using full-fledged IIS

最佳回答

Try replacing

context.Response.Headers.Add 

with

context.Response.AddHeader

(courtesy of this site)

I believe you have to be running IIS7 (in Integrated Pipeline mode) to use Headers.Add

问题回答

Right Click on your Web Project and Select "Use IIS Express..."





相关问题
handling exceptions IN Action Filters

Is there a better way to handle exceptions that occur inside an Action Filter itself in ASP .NET MVC? There re 2 ways I can think of at the moment. Using a try catch and setting the HTTP Status ...

既可捕获,又可举出例外。

我有一种办法,可以进入亚洲开发银行,因此,我国的亚行在多瑙河航道中的所有 st子都位于一个试捕区。 它正在追捕Kexception

Cross compiler exception handling - Can it be done safely?

I am doing some maintenance on a C++ windows dll library that is required to work with different VC++ compilers (as I don’t want to address different mangling schemes). I have already eliminated any ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

Watch a memory location/install data breakpoint from code?

We have a memory overwrite problem. At some point, during the course of our program, a memory location is being overwritten and causing our program to crash. the problem happens only in release mode. ...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签