使用Thinktecture.IdentityModel进行CORS。 httpContext为null并导致异常

时间:2022-06-02 00:13:32

i have installed the nuget package: "Thinktecture.IdentityModel" in order to open my API for CORS requests. I followed the instructions for opening the web api as given here:

我已经安装了nuget包:“Thinktecture.IdentityModel”,以便为CORS请求打开我的API。我按照这里给出的打开web api的说明进行了操作:

http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/

http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/

with the only difference of allowing all origins (just to see that it works) and changing the resource name to fit the controller I have. however on any request I get an exception thrown saying that httpContext is null (this is thrown from inside the package code).

唯一的区别是允许所有来源(只是为了看它工作)和更改资源名称以适应我拥有的控制器。但是在任何请求中我都会抛出一个异常,说httpContext为null(这是从包代码中抛出的)。

what could be the reason?

可能是什么原因?

edit: if you can't answer, perhaps tell me what other information might help you answer? at this point even wild guesses will be appreciated.

编辑:如果你不能回答,或许告诉我其他什么信息可能会帮助你回答?在这一点上,即使是疯狂的猜测也将受到赞赏。

1 个解决方案

#1


0  

Do you selfhost your API? HttpContext is only available when hosting in IIS (Express).

你自己托管你的API吗? HttpContext仅在IIS(Express)中托管时可用。

#1


0  

Do you selfhost your API? HttpContext is only available when hosting in IIS (Express).

你自己托管你的API吗? HttpContext仅在IIS(Express)中托管时可用。