本文介绍了在Orchard CMS中访问HttpConfiguration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Orchard 1.8.1中启用CORS(跨源请求).我关注了本文以达到目的.但是,我不知道如何为我的WebAPI控制器访问HttpConfiguration.我尝试使用ControllerContext.Configuration,但它似乎始终为NULL.

I would like to enable CORS (Cross-Origin Request) in Orchard 1.8.1. I followed this article for the purpose. However, I don't know how to access HttpConfiguration for my WebAPI Controller. I tried to use ControllerContext.Configuration, but it seems to be always NULL.

访问Orchard中的HttpConfiguration并调用EnableCors()的正确方法是什么?

What is the proper method to access HttpConfiguration in Orchard and to call EnableCors()?

谢谢.

推荐答案

当我发现Orchard使用GlobalConfiguration时,我创建了一个Shell钩子,以推动模块中的IOrchardShellEvents,并在Activated方法实现中调用了System.Web.Http. GlobalConfiguration.Configuration.EnableCors();

As I figured Orchard uses GlobalConfiguration, I created a shell hook impelmenting the IOrchardShellEvents in my module, and inside the Activated method implementation I called System.Web.Http.GlobalConfiguration.Configuration.EnableCors();

这篇关于在Orchard CMS中访问HttpConfiguration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 14:15