Access HttpConfiguration in Orchard CMS

无人久伴 提交于 2020-01-24 20:17:05

问题


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.

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

Thank you in advance.


回答1:


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();



来源:https://stackoverflow.com/questions/30285159/access-httpconfiguration-in-orchard-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!