What is the difference between Microsoft.AspNetCore.Mvc.ActionResult and System.Web.Mvc.ActionResult ?
When should you use one or the other one?
What is the difference between Microsoft.AspNetCore.Mvc.ActionResult and System.Web.Mvc.ActionResult ?
When should you use one or the other one?
kayes hasan
On
Microsoft.AspNetCore.Mvc.ActionResult
as it is showing, it is applied in asp.net core. this executes the result operation method asynchronusly. it is the default implementation of IActionResult.
System.Web.Mvc.ActionResult It is applied to ASP.NET MVC. it simply represents the result of an action method. It performs the operation synchronously.
Copyright © 2021 Jogjafile Inc.
The
System.Web.Mvcnamespace is used the .NET Framework. If your project is targetting the .NET Framework, useSystem.Web.Mvc.ActionResult.Below list is all return type from System.Web.Mvc.ActionResult :
ViewResult: Represents HTML and markup.EmptyResult: Represents no result.RedirectResult: Represents a redirection to a new URL.JsonResult: Represents a JavaScript Object Notation result that can be used in an AJAX application.JavaScriptResult: Represents a JavaScript script.ContentResult: Represents a plain text result.FileContentResult: Represents a downloadable file (with the binary content).FilePathResult: Represents a downloadable file (with a path).FileStreamResult: Represents a downloadable file (with a file stream).The
Microsoft.AspNetCore.Mvcnamespace is used in .NET Core. If your project is targetting .NET Core, useMicrosoft.AspNetCore.Mvc.ActionResult.ASP.NET Core offers the following options for web API controller action return types:
Specific typeIActionResultActionResult<T>List of common return types in Microsoft.AspNetCore.Mvc.ActionResult :
ViewResult: Represents HTML and markup.ContentResult: Represents content like plain text, XML, html.JsonResult: Represents a JavaScript Object Notation result that can be used in an AJAX application.PartialViewResult: Represents PartialView.RedirectResult: Represents a redirection to a new URL.RedirectToActionResult: Represents a redirection to specified action and controller.RedirectToPageResult: Represents a redirection to a specified pageName (It is mostly used in Razor pages).RedirectToRouteResult: Represents a route to redirect from one controller to another controller in cases we have more than one route.StatusCodeResult: Represents an HTTP status code.ViewComponentResult: Represents a "ViewComponent".ChallengeResult: on execution invokesHttpContext.ChallengeAsync.SignInResult: on execution invokesHttpContext.SignInAsyncSignOutResult: on execution invokesHttpContext.SignOutAsync.