Visual Studio 2008内置Web服务器需要集成管道模式来添加Http标头

发布于 2024-08-26 06:19:54 字数 677 浏览 4 评论 0原文

使用 Visual Studio 2008 和内置 Web 服务器。

在 Web 处理程序 .ashx 文件中,

    public void ProcessRequest(HttpContext context) {

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

当我尝试添加 HTTP 标头时,出现异常:

此操作需要集成 IIS 管道模式。

描述:未处理的异常 执行期间发生的 当前的网络请求。请查看 堆栈跟踪以获取有关的更多信息 错误及其起源 代码。

异常详细信息: System.PlatformNotSupportedException: 此操作需要集成IIS 管道模式。

我可以在 Internet 上找到有关此错误的信息,但需要有关如何启用集成管道模式(通过 web.config?)以允许操作 HTTP 标头的具体信息。

如何将内置Web服务器置于集成管道模式? 注意:不使用成熟的 IIS

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

硬不硬你别怂 2024-09-02 06:19:54

尝试替换

context.Response.Headers.Add 

context.Response.AddHeader

(由此网站提供

我相信您必须运行 IIS7(在集成管道模式下)才能使用 Headers.Add

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

讽刺将军 2024-09-02 06:19:54

右键单击您的 Web 项目并选择“使用 IIS Express...”

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文