0
我有下面的代碼(從here解除),我試圖在Linux服務器上運行w/mono 2.10.5。單聲道HttpContext.GetService
private static HttpContext GetCurrentContext(ControllerContext context) {
var currentApplication = (HttpApplication)context.HttpContext.GetService(typeof(HttpApplication));
if (currentApplication == null) {
throw new NullReferenceException("currentApplication");
}
return currentApplication.Context;
}
當單上運行,我得到下面的異常,這是足夠簡單:
System.NotImplementedException: The requested feature is not
implemented. at System.Web.HttpContextWrapper.GetService
(System.Type serviceType) [0x00000] in <filename unknown>:0
是否存在已知的解決方法,我可以用它來完成對單聲道同樣的結果?
舉起,缺口等等 - - 所有的聲音都比被盜的聲音好;)你在中途得到了我 - GetService被用於將HttpContextBase轉換爲HttpContext(根據ELMAH的要求)。從這篇文章的評論(http://stackoverflow.com/a/4567707/794)看來,context.HttpContext.ApplicationInstance.Context將做到這一點(並在單聲道工作)。如果你想編輯你的答案,我會接受它。 – AlexCuse 2012-02-11 21:21:03