2

Is there any replacement for the below code in .NET Core?

filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary
{
    {"controller", "Login"},
    {"action", "LogoutSession"}
});

Because this code causes an error in ASP.NET Core MVC

The type or namespace name 'Routing' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

enter image description here

0

2 Answers 2

2

RedirectToRouteResult now lives in Microsoft.AspNetCore.Mvc

https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.redirecttorouteresult?view=aspnetcore-6.0

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar issue trying to use that RouteValueDictionary class. Found the reference to this class here https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.routing.routevaluedictionary?view=aspnetcore-7.0 wich indicates the namespace, assembly and package necessary to use it. So, not in System.Web.Routing anymore. I installed the Microsoft.AspNetCore.Routing.Abstractions package in my project and it worked. Hope it helps you or anyone else here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.