Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionContext gone in Microsoft.AspNetCore.Mvc.Controller

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

after i changed my Version to AspNetCore 1.0.0-preview1

this is Controller class (after Change):

enter image description here

And from "Microsoft.AspNet.Mvc" before change :

enter image description here

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();
like image 953
Ahad Porkar Avatar asked May 17 '16 21:05

Ahad Porkar


People also ask

What is ActionExecutingContext?

ActionExecutingContext(ControllerContext, ActionDescriptor, IDictionary<String,Object>) Initializes a new instance of the ActionExecutingContext class by using the specified controller context, action descriptor, and action-method parameters.

What is ControllerContext MVC?

ControllerContext(ControllerContext) Initializes a new instance of the ControllerContext class by using the specified controller context. ControllerContext(HttpContextBase, RouteData, ControllerBase)

What is ASP Net mvc6?

ASP.NET MVC is a web application framework developed by Microsoft that implements the model–view–controller (MVC) pattern. It is no longer in active development. It is open-source software, apart from the ASP.NET Web Forms component, which is proprietary.

Which of the Microsoft ASP NET core MVC classes support views?

ASP.NET Core MVC views use the Razor view engine to render views. Razor is a compact, expressive and fluid template markup language for defining views using embedded C# code. Razor is used to dynamically generate web content on the server. You can cleanly mix server code with client side content and code.


1 Answers

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

like image 72
fran.tonkovic Avatar answered Sep 20 '22 03:09

fran.tonkovic