Microsoft.AspNetCore.Mvc.Controller中包含ActionContext [英] ActionContext gone in Microsoft.AspNetCore.Mvc.Controller

查看:407
本文介绍了Microsoft.AspNetCore.Mvc.Controller中包含ActionContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Microsoft.AspNetCore.Mvc.Controller中找不到ActionContext

I cant find ActionContext in Microsoft.AspNetCore.Mvc.Controller

在我将版本更改为AspNetCore 1.0.0-preview1

after i changed my Version to AspNetCore 1.0.0-preview1

这是Controller类(更改后):

this is Controller class (after Change):

并从" Microsoft.AspNet.Mvc "更改之前:

以及更新前旧方法中的代码:

and code from old method before update :

        this.Agent = ControllerInfo.Request.Headers["User-Agent"];
        this.IP = ControllerInfo.HttpContext.Features.Get<IHttpConnectionFeature>()?.LocalIpAddress?.ToString(); 
        this.RemoteIP = ControllerInfo.HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress.ToString();
        this.Refrence = ControllerInfo.ActionContext.RouteData.Values["controller"].ToString() + "/" + ControllerInfo.ActionContext.RouteData.Values["action"].ToString();

推荐答案

我将 ActionContext 替换为 ControllerContext ,它对我有用. 不过,我不知道这是否是正式的迁移步骤.

I replaced ActionContext with ControllerContext, and it works for me. I don't know if it's an official migration step, though.

这篇关于Microsoft.AspNetCore.Mvc.Controller中包含ActionContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆