ControllerBase Class

A base class for an MVC controller without view support.

Namespace
Microsoft.AspNetCore.Mvc
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

public abstract class ControllerBase
class Microsoft.AspNetCore.Mvc.ControllerBase

Methods

BadRequest()

Creates an Microsoft.AspNetCore.Mvc.BadRequestResult that produces a Bad Request (400) response.

Return type:Microsoft.AspNetCore.Mvc.BadRequestResult
Returns:The created Microsoft.AspNetCore.Mvc.BadRequestResult for the response.
public virtual BadRequestResult BadRequest()
BadRequest(Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary)

Creates an Microsoft.AspNetCore.Mvc.BadRequestObjectResult that produces a Bad Request (400) response.

Return type:Microsoft.AspNetCore.Mvc.BadRequestObjectResult
Returns:The created Microsoft.AspNetCore.Mvc.BadRequestObjectResult for the response.
public virtual BadRequestObjectResult BadRequest(ModelStateDictionary modelState)
BadRequest(System.Object)

Creates an Microsoft.AspNetCore.Mvc.BadRequestObjectResult that produces a Bad Request (400) response.

Return type:Microsoft.AspNetCore.Mvc.BadRequestObjectResult
Returns:The created Microsoft.AspNetCore.Mvc.BadRequestObjectResult for the response.
public virtual BadRequestObjectResult BadRequest(object error)
Challenge()

Creates a Microsoft.AspNetCore.Mvc.ChallengeResult.

Return type:Microsoft.AspNetCore.Mvc.ChallengeResult
Returns:The created Microsoft.AspNetCore.Mvc.ChallengeResult for the response.
public virtual ChallengeResult Challenge()
Challenge(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties)

Creates a Microsoft.AspNetCore.Mvc.ChallengeResult with the specified <em>properties</em>.

Arguments:properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) – Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties used to perform the authentication challenge.
Return type:Microsoft.AspNetCore.Mvc.ChallengeResult
Returns:The created Microsoft.AspNetCore.Mvc.ChallengeResult for the response.
public virtual ChallengeResult Challenge(AuthenticationProperties properties)
Challenge(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[])

Creates a Microsoft.AspNetCore.Mvc.ChallengeResult with the specified specified authentication schemes and <em>properties</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.ChallengeResult

Returns:

The created Microsoft.AspNetCore.Mvc.ChallengeResult for the response.

public virtual ChallengeResult Challenge(AuthenticationProperties properties, params string[] authenticationSchemes)
Challenge(System.String[])

Creates a Microsoft.AspNetCore.Mvc.ChallengeResult with the specified authentication schemes.

Arguments:authenticationSchemes (System.String<System.String>[]) – The authentication schemes to challenge.
Return type:Microsoft.AspNetCore.Mvc.ChallengeResult
Returns:The created Microsoft.AspNetCore.Mvc.ChallengeResult for the response.
public virtual ChallengeResult Challenge(params string[] authenticationSchemes)
Content(System.String)

Creates a Microsoft.AspNetCore.Mvc.ContentResult object by specifying a <em>content</em> string.

Arguments:content (System.String) – The content to write to the response.
Return type:Microsoft.AspNetCore.Mvc.ContentResult
Returns:The created Microsoft.AspNetCore.Mvc.ContentResult object for the response.
public virtual ContentResult Content(string content)
Content(System.String, Microsoft.Net.Http.Headers.MediaTypeHeaderValue)

Creates a Microsoft.AspNetCore.Mvc.ContentResult object by specifying a <em>content</em> string and a <em>contentType</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.ContentResult

Returns:

The created Microsoft.AspNetCore.Mvc.ContentResult object for the response.

public virtual ContentResult Content(string content, MediaTypeHeaderValue contentType)
Content(System.String, System.String)

Creates a Microsoft.AspNetCore.Mvc.ContentResult object by specifying a <em>content</em> string and a content type.

Arguments:
  • content (System.String) – The content to write to the response.
  • contentType (System.String) – The content type (MIME type).
Return type:

Microsoft.AspNetCore.Mvc.ContentResult

Returns:

The created Microsoft.AspNetCore.Mvc.ContentResult object for the response.

public virtual ContentResult Content(string content, string contentType)
Content(System.String, System.String, System.Text.Encoding)

Creates a Microsoft.AspNetCore.Mvc.ContentResult object by specifying a <em>content</em> string, a <em>contentType</em>, and <em>contentEncoding</em>.

Arguments:
  • content (System.String) – The content to write to the response.
  • contentType (System.String) – The content type (MIME type).
  • contentEncoding (System.Text.Encoding) – The content encoding.
Return type:

Microsoft.AspNetCore.Mvc.ContentResult

Returns:

The created Microsoft.AspNetCore.Mvc.ContentResult object for the response.

public virtual ContentResult Content(string content, string contentType, Encoding contentEncoding)
Created(System.String, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedResult object that produces a Created (201) response.

Arguments:
  • uri (System.String) – The URI at which the content has been created.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedResult for the response.

public virtual CreatedResult Created(string uri, object value)
Created(System.Uri, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedResult object that produces a Created (201) response.

Arguments:
  • uri (System.Uri) – The URI at which the content has been created.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedResult for the response.

public virtual CreatedResult Created(Uri uri, object value)
CreatedAtAction(System.String, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtActionResult object that produces a Created (201) response.

Arguments:
  • actionName (System.String) – The name of the action to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtActionResult for the response.

public virtual CreatedAtActionResult CreatedAtAction(string actionName, object value)
CreatedAtAction(System.String, System.Object, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtActionResult object that produces a Created (201) response.

Arguments:
  • actionName (System.String) – The name of the action to use for generating the URL.
  • routeValues (System.Object) – The route data to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtActionResult for the response.

public virtual CreatedAtActionResult CreatedAtAction(string actionName, object routeValues, object value)
CreatedAtAction(System.String, System.String, System.Object, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtActionResult object that produces a Created (201) response.

Arguments:
  • actionName (System.String) – The name of the action to use for generating the URL.
  • controllerName (System.String) – The name of the controller to use for generating the URL.
  • routeValues (System.Object) – The route data to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtActionResult for the response.

public virtual CreatedAtActionResult CreatedAtAction(string actionName, string controllerName, object routeValues, object value)
CreatedAtRoute(System.Object, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtRouteResult object that produces a Created (201) response.

Arguments:
  • routeValues (System.Object) – The route data to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtRouteResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtRouteResult for the response.

public virtual CreatedAtRouteResult CreatedAtRoute(object routeValues, object value)
CreatedAtRoute(System.String, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtRouteResult object that produces a Created (201) response.

Arguments:
  • routeName (System.String) – The name of the route to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtRouteResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtRouteResult for the response.

public virtual CreatedAtRouteResult CreatedAtRoute(string routeName, object value)
CreatedAtRoute(System.String, System.Object, System.Object)

Creates a Microsoft.AspNetCore.Mvc.CreatedAtRouteResult object that produces a Created (201) response.

Arguments:
  • routeName (System.String) – The name of the route to use for generating the URL.
  • routeValues (System.Object) – The route data to use for generating the URL.
  • value (System.Object) – The content value to format in the entity body.
Return type:

Microsoft.AspNetCore.Mvc.CreatedAtRouteResult

Returns:

The created Microsoft.AspNetCore.Mvc.CreatedAtRouteResult for the response.

public virtual CreatedAtRouteResult CreatedAtRoute(string routeName, object routeValues, object value)
File(System.Byte[], System.String)

Returns a file with the specified <em>fileContents</em> as content and the specified <em>contentType</em> as the Content-Type.

Arguments:
  • fileContents (System.Byte<System.Byte>[]) – The file contents.
  • contentType (System.String) – The Content-Type of the file.
Return type:

Microsoft.AspNetCore.Mvc.FileContentResult

Returns:

The created Microsoft.AspNetCore.Mvc.FileContentResult for the response.

public virtual FileContentResult File(byte[] fileContents, string contentType)
File(System.Byte[], System.String, System.String)

Returns a file with the specified <em>fileContents</em> as content, the specified <em>contentType</em> as the Content-Type and the specified <em>fileDownloadName</em> as the suggested file name.

Arguments:
  • fileContents (System.Byte<System.Byte>[]) – The file contents.
  • contentType (System.String) – The Content-Type of the file.
  • fileDownloadName (System.String) – The suggested file name.
Return type:

Microsoft.AspNetCore.Mvc.FileContentResult

Returns:

The created Microsoft.AspNetCore.Mvc.FileContentResult for the response.

public virtual FileContentResult File(byte[] fileContents, string contentType, string fileDownloadName)
File(System.IO.Stream, System.String)

Returns a file in the specified <em>fileStream</em> with the specified <em>contentType</em> as the Content-Type.

Arguments:
  • fileStream (System.IO.Stream) – The System.IO.Stream with the contents of the file.
  • contentType (System.String) – The Content-Type of the file.
Return type:

Microsoft.AspNetCore.Mvc.FileStreamResult

Returns:

The created Microsoft.AspNetCore.Mvc.FileStreamResult for the response.

public virtual FileStreamResult File(Stream fileStream, string contentType)
File(System.IO.Stream, System.String, System.String)

Returns a file in the specified <em>fileStream</em> with the specified <em>contentType</em> as the Content-Type and the specified <em>fileDownloadName</em> as the suggested file name.

Arguments:
  • fileStream (System.IO.Stream) – The System.IO.Stream with the contents of the file.
  • contentType (System.String) – The Content-Type of the file.
  • fileDownloadName (System.String) – The suggested file name.
Return type:

Microsoft.AspNetCore.Mvc.FileStreamResult

Returns:

The created Microsoft.AspNetCore.Mvc.FileStreamResult for the response.

public virtual FileStreamResult File(Stream fileStream, string contentType, string fileDownloadName)
File(System.String, System.String)

Returns the file specified by <em>virtualPath</em> with the specified <em>contentType</em> as the Content-Type.

Arguments:
  • virtualPath (System.String) – The virtual path of the file to be returned.
  • contentType (System.String) – The Content-Type of the file.
Return type:

Microsoft.AspNetCore.Mvc.VirtualFileResult

Returns:

The created Microsoft.AspNetCore.Mvc.VirtualFileResult for the response.

public virtual VirtualFileResult File(string virtualPath, string contentType)
File(System.String, System.String, System.String)

Returns the file specified by <em>virtualPath</em> with the specified <em>contentType</em> as the Content-Type and the specified <em>fileDownloadName</em> as the suggested file name.

Arguments:
  • virtualPath (System.String) – The virtual path of the file to be returned.
  • contentType (System.String) – The Content-Type of the file.
  • fileDownloadName (System.String) – The suggested file name.
Return type:

Microsoft.AspNetCore.Mvc.VirtualFileResult

Returns:

The created Microsoft.AspNetCore.Mvc.VirtualFileResult for the response.

public virtual VirtualFileResult File(string virtualPath, string contentType, string fileDownloadName)
Forbid()

Creates a Microsoft.AspNetCore.Mvc.ForbidResult.

Return type:Microsoft.AspNetCore.Mvc.ForbidResult
Returns:The created Microsoft.AspNetCore.Mvc.ForbidResult for the response.
public virtual ForbidResult Forbid()
Forbid(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties)

Creates a Microsoft.AspNetCore.Mvc.ForbidResult with the specified <em>properties</em>.

Arguments:properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) – Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties used to perform the authentication challenge.
Return type:Microsoft.AspNetCore.Mvc.ForbidResult
Returns:The created Microsoft.AspNetCore.Mvc.ForbidResult for the response.
public virtual ForbidResult Forbid(AuthenticationProperties properties)
Forbid(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[])

Creates a Microsoft.AspNetCore.Mvc.ForbidResult with the specified specified authentication schemes and <em>properties</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.ForbidResult

Returns:

The created Microsoft.AspNetCore.Mvc.ForbidResult for the response.

public virtual ForbidResult Forbid(AuthenticationProperties properties, params string[] authenticationSchemes)
Forbid(System.String[])

Creates a Microsoft.AspNetCore.Mvc.ForbidResult with the specified authentication schemes.

Arguments:authenticationSchemes (System.String<System.String>[]) – The authentication schemes to challenge.
Return type:Microsoft.AspNetCore.Mvc.ForbidResult
Returns:The created Microsoft.AspNetCore.Mvc.ForbidResult for the response.
public virtual ForbidResult Forbid(params string[] authenticationSchemes)
LocalRedirect(System.String)

Creates a Microsoft.AspNetCore.Mvc.LocalRedirectResult object that redirects to the specified local <em>localUrl</em>.

Arguments:localUrl (System.String) – The local URL to redirect to.
Return type:Microsoft.AspNetCore.Mvc.LocalRedirectResult
Returns:The created Microsoft.AspNetCore.Mvc.LocalRedirectResult for the response.
public virtual LocalRedirectResult LocalRedirect(string localUrl)
LocalRedirectPermanent(System.String)

Creates a Microsoft.AspNetCore.Mvc.LocalRedirectResult object with Microsoft.AspNetCore.Mvc.LocalRedirectResult.Permanent set to true using the specified <em>localUrl</em>.

Arguments:localUrl (System.String) – The local URL to redirect to.
Return type:Microsoft.AspNetCore.Mvc.LocalRedirectResult
Returns:The created Microsoft.AspNetCore.Mvc.LocalRedirectResult for the response.
public virtual LocalRedirectResult LocalRedirectPermanent(string localUrl)
NoContent()

Creates a Microsoft.AspNetCore.Mvc.NoContentResult object that produces an empty No Content (204) response.

Return type:Microsoft.AspNetCore.Mvc.NoContentResult
Returns:The created Microsoft.AspNetCore.Mvc.NoContentResult object for the response.
public virtual NoContentResult NoContent()
NotFound()

Creates an Microsoft.AspNetCore.Mvc.NotFoundResult that produces a Not Found (404) response.

Return type:Microsoft.AspNetCore.Mvc.NotFoundResult
Returns:The created Microsoft.AspNetCore.Mvc.NotFoundResult for the response.
public virtual NotFoundResult NotFound()
NotFound(System.Object)

Creates an Microsoft.AspNetCore.Mvc.NotFoundObjectResult that produces a Not Found (404) response.

Return type:Microsoft.AspNetCore.Mvc.NotFoundObjectResult
Returns:The created Microsoft.AspNetCore.Mvc.NotFoundObjectResult for the response.
public virtual NotFoundObjectResult NotFound(object value)
Ok()

Creates a Microsoft.AspNetCore.Mvc.OkResult object that produces an empty OK (200) response.

Return type:Microsoft.AspNetCore.Mvc.OkResult
Returns:The created Microsoft.AspNetCore.Mvc.OkResult for the response.
public virtual OkResult Ok()
Ok(System.Object)

Creates an Microsoft.AspNetCore.Mvc.OkObjectResult object that produces an OK (200) response.

Arguments:value (System.Object) – The content value to format in the entity body.
Return type:Microsoft.AspNetCore.Mvc.OkObjectResult
Returns:The created Microsoft.AspNetCore.Mvc.OkObjectResult for the response.
public virtual OkObjectResult Ok(object value)
PhysicalFile(System.String, System.String)

Returns the file specified by <em>physicalPath</em> with the specified <em>contentType</em> as the Content-Type.

Arguments:
  • physicalPath (System.String) – The physical path of the file to be returned.
  • contentType (System.String) – The Content-Type of the file.
Return type:

Microsoft.AspNetCore.Mvc.PhysicalFileResult

Returns:

The created Microsoft.AspNetCore.Mvc.PhysicalFileResult for the response.

public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType)
PhysicalFile(System.String, System.String, System.String)

Returns the file specified by <em>physicalPath</em> with the specified <em>contentType</em> as the Content-Type and the specified <em>fileDownloadName</em> as the suggested file name.

Arguments:
  • physicalPath (System.String) – The physical path of the file to be returned.
  • contentType (System.String) – The Content-Type of the file.
  • fileDownloadName (System.String) – The suggested file name.
Return type:

Microsoft.AspNetCore.Mvc.PhysicalFileResult

Returns:

The created Microsoft.AspNetCore.Mvc.PhysicalFileResult for the response.

public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, string fileDownloadName)
Redirect(System.String)

Creates a Microsoft.AspNetCore.Mvc.RedirectResult object that redirects to the specified <em>url</em>.

Arguments:url (System.String) – The URL to redirect to.
Return type:Microsoft.AspNetCore.Mvc.RedirectResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectResult for the response.
public virtual RedirectResult Redirect(string url)
RedirectPermanent(System.String)

Creates a Microsoft.AspNetCore.Mvc.RedirectResult object with Microsoft.AspNetCore.Mvc.RedirectResult.Permanent set to true using the specified <em>url</em>.

Arguments:url (System.String) – The URL to redirect to.
Return type:Microsoft.AspNetCore.Mvc.RedirectResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectResult for the response.
public virtual RedirectResult RedirectPermanent(string url)
RedirectToAction(System.String)

Redirects to the specified action using the <em>actionName</em>.

Arguments:actionName (System.String) – The name of the action.
Return type:Microsoft.AspNetCore.Mvc.RedirectToActionResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.
public virtual RedirectToActionResult RedirectToAction(string actionName)
RedirectToAction(System.String, System.Object)

Redirects to the specified action using the <em>actionName</em> and <em>routeValues</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToAction(string actionName, object routeValues)
RedirectToAction(System.String, System.String)

Redirects to the specified action using the <em>actionName</em> and the <em>controllerName</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToAction(string actionName, string controllerName)
RedirectToAction(System.String, System.String, System.Object)

Redirects to the specified action using the specified <em>actionName</em>, <em>controllerName</em>, and <em>routeValues</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToAction(string actionName, string controllerName, object routeValues)
RedirectToActionPermanent(System.String)

Redirects to the specified action with Microsoft.AspNetCore.Mvc.RedirectToActionResult.Permanent set to true using the specified <em>actionName</em>.

Arguments:actionName (System.String) – The name of the action.
Return type:Microsoft.AspNetCore.Mvc.RedirectToActionResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.
public virtual RedirectToActionResult RedirectToActionPermanent(string actionName)
RedirectToActionPermanent(System.String, System.Object)

Redirects to the specified action with Microsoft.AspNetCore.Mvc.RedirectToActionResult.Permanent set to true using the specified <em>actionName</em> and <em>routeValues</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToActionPermanent(string actionName, object routeValues)
RedirectToActionPermanent(System.String, System.String)

Redirects to the specified action with Microsoft.AspNetCore.Mvc.RedirectToActionResult.Permanent set to true using the specified <em>actionName</em> and <em>controllerName</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToActionPermanent(string actionName, string controllerName)
RedirectToActionPermanent(System.String, System.String, System.Object)

Redirects to the specified action with Microsoft.AspNetCore.Mvc.RedirectToActionResult.Permanent set to true using the specified <em>actionName</em>, <em>controllerName</em>, and <em>routeValues</em>.

Arguments:
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToActionResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToActionResult for the response.

public virtual RedirectToActionResult RedirectToActionPermanent(string actionName, string controllerName, object routeValues)
RedirectToRoute(System.Object)

Redirects to the specified route using the specified <em>routeValues</em>.

Arguments:routeValues (System.Object) – The parameters for a route.
Return type:Microsoft.AspNetCore.Mvc.RedirectToRouteResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.
public virtual RedirectToRouteResult RedirectToRoute(object routeValues)
RedirectToRoute(System.String)

Redirects to the specified route using the specified <em>routeName</em>.

Arguments:routeName (System.String) – The name of the route.
Return type:Microsoft.AspNetCore.Mvc.RedirectToRouteResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.
public virtual RedirectToRouteResult RedirectToRoute(string routeName)
RedirectToRoute(System.String, System.Object)

Redirects to the specified route using the specified <em>routeName</em> and <em>routeValues</em>.

Arguments:
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToRouteResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.

public virtual RedirectToRouteResult RedirectToRoute(string routeName, object routeValues)
RedirectToRoutePermanent(System.Object)

Redirects to the specified route with Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanent set to true using the specified <em>routeValues</em>.

Arguments:routeValues (System.Object) – The parameters for a route.
Return type:Microsoft.AspNetCore.Mvc.RedirectToRouteResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.
public virtual RedirectToRouteResult RedirectToRoutePermanent(object routeValues)
RedirectToRoutePermanent(System.String)

Redirects to the specified route with Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanent set to true using the specified <em>routeName</em>.

Arguments:routeName (System.String) – The name of the route.
Return type:Microsoft.AspNetCore.Mvc.RedirectToRouteResult
Returns:The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.
public virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName)
RedirectToRoutePermanent(System.String, System.Object)

Redirects to the specified route with Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanent set to true using the specified <em>routeName</em> and <em>routeValues</em>.

Arguments:
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNetCore.Mvc.RedirectToRouteResult

Returns:

The created Microsoft.AspNetCore.Mvc.RedirectToRouteResult for the response.

public virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName, object routeValues)
SignIn(System.Security.Claims.ClaimsPrincipal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String)

Creates a Microsoft.AspNetCore.Mvc.SignInResult with the specified specified authentication scheme and <em>properties</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.SignInResult

Returns:

The created Microsoft.AspNetCore.Mvc.SignInResult for the response.

public virtual SignInResult SignIn(ClaimsPrincipal principal, AuthenticationProperties properties, string authenticationScheme)
SignIn(System.Security.Claims.ClaimsPrincipal, System.String)

Creates a Microsoft.AspNetCore.Mvc.SignInResult with the specified authentication scheme.

Arguments:
  • principal (System.Security.Claims.ClaimsPrincipal) – The System.Security.Claims.ClaimsPrincipal containing the user claims.
  • authenticationScheme (System.String) – The authentication scheme to use for the sign-in operation.
Return type:

Microsoft.AspNetCore.Mvc.SignInResult

Returns:

The created Microsoft.AspNetCore.Mvc.SignInResult for the response.

public virtual SignInResult SignIn(ClaimsPrincipal principal, string authenticationScheme)
SignOut(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[])

Creates a Microsoft.AspNetCore.Mvc.SignOutResult with the specified specified authentication schemes and <em>properties</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.SignOutResult

Returns:

The created Microsoft.AspNetCore.Mvc.SignOutResult for the response.

public virtual SignOutResult SignOut(AuthenticationProperties properties, params string[] authenticationSchemes)
SignOut(System.String[])

Creates a Microsoft.AspNetCore.Mvc.SignOutResult with the specified authentication schemes.

Arguments:authenticationSchemes (System.String<System.String>[]) – The authentication schemes to use for the sign-out operation.
Return type:Microsoft.AspNetCore.Mvc.SignOutResult
Returns:The created Microsoft.AspNetCore.Mvc.SignOutResult for the response.
public virtual SignOutResult SignOut(params string[] authenticationSchemes)
StatusCode(System.Int32)

Creates a Microsoft.AspNetCore.Mvc.StatusCodeResult object by specifying a <em>statusCode</em>.

Arguments:statusCode (System.Int32) – The status code to set on the response.
Return type:Microsoft.AspNetCore.Mvc.StatusCodeResult
Returns:The created Microsoft.AspNetCore.Mvc.StatusCodeResult object for the response.
public virtual StatusCodeResult StatusCode(int statusCode)
StatusCode(System.Int32, System.Object)

Creates a Microsoft.AspNetCore.Mvc.ObjectResult object by specifying a <em>statusCode</em> and <em>value</em>

Arguments:
Return type:

Microsoft.AspNetCore.Mvc.ObjectResult

Returns:

The created Microsoft.AspNetCore.Mvc.ObjectResult object for the response.

public virtual ObjectResult StatusCode(int statusCode, object value)
TryUpdateModelAsync(System.Object, System.Type, System.String)

Updates the specified <em>model</em> instance using values from the controller’s current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider and a <em>prefix</em>.

Arguments:
  • model (System.Object) – The model instance to update.
  • modelType (System.Type) – The type of model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public virtual Task<bool> TryUpdateModelAsync(object model, Type modelType, string prefix)
TryUpdateModelAsync(System.Object, System.Type, System.String, Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider, System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata, System.Boolean>)

Updates the specified <em>model</em> instance using the <em>valueProvider</em> and a <em>prefix</em>.

Arguments:
  • model (System.Object) – The model instance to update.
  • modelType (System.Type) – The type of model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the <em>valueProvider</em>.
  • valueProvider (Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider) – The Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider used for looking up values.
  • propertyFilter (System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata>) – A predicate which can be used to filter properties at runtime.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public Task<bool> TryUpdateModelAsync(object model, Type modelType, string prefix, IValueProvider valueProvider, Func<ModelMetadata, bool> propertyFilter)
TryUpdateModelAsync<TModel>(TModel)

Updates the specified <em>model</em> instance using values from the controller’s current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider.

Arguments:model (TModel) – The model instance to update.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.
public virtual Task<bool> TryUpdateModelAsync<TModel>(TModel model)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String)

Updates the specified <em>model</em> instance using values from the controller’s current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider and a <em>prefix</em>.

Arguments:
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public virtual Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String, Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider)

Updates the specified <em>model</em> instance using the <em>valueProvider</em> and a <em>prefix</em>.

Arguments:
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public virtual Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, IValueProvider valueProvider)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String, Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider, System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata, System.Boolean>)

Updates the specified <em>model</em> instance using the <em>valueProvider</em> and a <em>prefix</em>.

Arguments:
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, IValueProvider valueProvider, Func<ModelMetadata, bool> propertyFilter)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String, Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider, System.Linq.Expressions.Expression<System.Func<TModel, System.Object>>[])

Updates the specified <em>model</em> instance using the <em>valueProvider</em> and a <em>prefix</em>.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the <em>valueProvider</em>.
  • valueProvider (Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider) – The Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider used for looking up values.
  • includeExpressions (System.Linq.Expressions.Expression<System.Linq.Expressions.Expression`1>{System.Func<System.Func`2>{TModel, System.Object<System.Object>}}[]) – System.Linq.Expressions.Expression(s) which represent top-level properties which need to be included for the current model.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, IValueProvider valueProvider, params Expression<Func<TModel, object>>[] includeExpressions)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String, System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata, System.Boolean>)

Updates the specified <em>model</em> instance using values from the controller’s current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider and a <em>prefix</em>.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider.
  • propertyFilter (System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata>) – A predicate which can be used to filter properties at runtime.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, Func<ModelMetadata, bool> propertyFilter)where TModel : class
TryUpdateModelAsync<TModel>(TModel, System.String, System.Linq.Expressions.Expression<System.Func<TModel, System.Object>>[])

Updates the specified <em>model</em> instance using values from the controller’s current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider and a <em>prefix</em>.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider.
  • includeExpressions (System.Linq.Expressions.Expression<System.Linq.Expressions.Expression`1>{System.Func<System.Func`2>{TModel, System.Object<System.Object>}}[]) – System.Linq.Expressions.Expression(s) which represent top-level properties which need to be included for the current model.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A System.Threading.Tasks.Task that on completion returns <code>true</code> if the update is successful.

public Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, params Expression<Func<TModel, object>>[] includeExpressions)where TModel : class
TryValidateModel(System.Object)

Validates the specified <em>model</em> instance.

Arguments:model (System.Object) – The model to validate.
Return type:System.Boolean
Returns:<code>true</code> if the Microsoft.AspNetCore.Mvc.ControllerBase.ModelState is valid; <code>false</code> otherwise.
public virtual bool TryValidateModel(object model)
TryValidateModel(System.Object, System.String)

Validates the specified <em>model</em> instance.

Arguments:
Return type:

System.Boolean

Returns:

<code>true</code> if the Microsoft.AspNetCore.Mvc.ControllerBase.ModelState is valid;<code>false</code> otherwise.

public virtual bool TryValidateModel(object model, string prefix)
Unauthorized()

Creates an Microsoft.AspNetCore.Mvc.UnauthorizedResult that produces an Unauthorized (401) response.

Return type:Microsoft.AspNetCore.Mvc.UnauthorizedResult
Returns:The created Microsoft.AspNetCore.Mvc.UnauthorizedResult for the response.
public virtual UnauthorizedResult Unauthorized()

Properties

Microsoft.AspNetCore.Mvc.ControllerBase.ControllerContext

Gets or sets the Microsoft.AspNetCore.Mvc.ControllerContext.

Return type:Microsoft.AspNetCore.Mvc.ControllerContext
public ControllerContext ControllerContext { get; set; }
Microsoft.AspNetCore.Mvc.ControllerBase.HttpContext

Gets the Microsoft.AspNetCore.Http.HttpContext for the executing action.

Return type:Microsoft.AspNetCore.Http.HttpContext
public HttpContext HttpContext { get; }
Microsoft.AspNetCore.Mvc.ControllerBase.MetadataProvider

Gets or sets the Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider
public IModelMetadataProvider MetadataProvider { get; set; }
Microsoft.AspNetCore.Mvc.ControllerBase.ModelBinderFactory

Gets or sets the Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderFactory.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderFactory
public IModelBinderFactory ModelBinderFactory { get; set; }
Microsoft.AspNetCore.Mvc.ControllerBase.ModelState

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary that contains the state of the model and of model-binding validation.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary
public ModelStateDictionary ModelState { get; }
Microsoft.AspNetCore.Mvc.ControllerBase.ObjectValidator

Gets or sets the Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IObjectModelValidator.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IObjectModelValidator
public IObjectModelValidator ObjectValidator { get; set; }
Microsoft.AspNetCore.Mvc.ControllerBase.Request

Gets the Microsoft.AspNetCore.Http.HttpRequest for the executing action.

Return type:Microsoft.AspNetCore.Http.HttpRequest
public HttpRequest Request { get; }
Microsoft.AspNetCore.Mvc.ControllerBase.Response

Gets the Microsoft.AspNetCore.Http.HttpResponse for the executing action.

Return type:Microsoft.AspNetCore.Http.HttpResponse
public HttpResponse Response { get; }
Microsoft.AspNetCore.Mvc.ControllerBase.RouteData

Gets the Microsoft.AspNetCore.Routing.RouteData for the executing action.

Return type:Microsoft.AspNetCore.Routing.RouteData
public RouteData RouteData { get; }
Microsoft.AspNetCore.Mvc.ControllerBase.Url

Gets or sets the Microsoft.AspNetCore.Mvc.IUrlHelper.

Return type:Microsoft.AspNetCore.Mvc.IUrlHelper
public IUrlHelper Url { get; set; }
Microsoft.AspNetCore.Mvc.ControllerBase.User

Gets or sets the System.Security.Claims.ClaimsPrincipal for user associated with the executing action.

Return type:System.Security.Claims.ClaimsPrincipal
public ClaimsPrincipal User { get; }