HttpSelfHostServer and HttpContext.Current

后端 未结 2 723
一生所求
一生所求 2020-12-01 06:33

I\'m working on a self-hosted ASP.NET web api-application. Everything works fine, but now I\'m struggling with HttpContext:

I need to save session-infor

2条回答
  •  春和景丽
    2020-12-01 07:30

    You won't be able to use HttpContext in a self-hosted environment. HttpContext is set by the ASP.Net pipeline, which you won't have if you don't run under IIS/ASP.Net.

    The HttpContext is only available in the Web-Hosting mode, in which the HttpControllerHandler creates the request.

    FYI- I invite you to read the following great articles from Pedro Felix to better understand the different hosting models:

    • HTTP processing architecture overview
    • Web-hosting
    • Self-hosting

提交回复
热议问题