【发布时间】:2015-05-17 09:02:12
【问题描述】:
我想在 Orchard 1.8.1 中启用 CORS(跨域请求)。为此,我关注了this article。但是,我不知道如何访问我的 WebAPI 控制器的 HttpConfiguration。我尝试使用 ControllerContext.Configuration,但它似乎始终为 NULL。
在 Orchard 中访问 HttpConfiguration 并调用 EnableCors() 的正确方法是什么?
提前谢谢你。
【问题讨论】:
-
当我认为 Orchard 使用 GlobalConfiguration 时,我在我的模块中创建了一个执行 IOrchardShellEvents 的 shell 挂钩,并在 Activated 方法实现中调用了 System.Web.Http.GlobalConfiguration.Configuration.EnableCors();
-
就是这样。您应该将此作为答案发布