私は次のコードを持っています(hereから持ち上げました)、私はモノラル2.10.5のLinuxサーバーでそれを実行しようとしています。モノで実行する場合モノラルで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
方法がありますがはを解除したコードわからない
盗まれた権利よりも音が良くなりました;)途中でGetServiceを使用してHttpContextBaseをHttpContextに変換しています(ELMAHの必要に応じて)。この記事(http://stackoverflow.com/a/4567707/794)のコメントから、context.HttpContext.ApplicationInstance.Contextはトリックを行い、モノで作業するように見えます。あなたの答えを編集したい場合は、私はそれを受け入れます。 – AlexCuse