ControllerBase Class¶
A base class for an MVC controller without view support.
- Namespace
Microsoft.AspNetCore.Mvc- Assemblies
- Microsoft.AspNetCore.Mvc.Core
Methods¶
-
BadRequest()¶ Creates an
Microsoft.AspNetCore.Mvc.BadRequestResultthat produces a Bad Request (400) response.Return type: Microsoft.AspNetCore.Mvc.BadRequestResult Returns: The created Microsoft.AspNetCore.Mvc.BadRequestResultfor the response.public virtual BadRequestResult BadRequest()
-
BadRequest(Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary) Creates an
Microsoft.AspNetCore.Mvc.BadRequestObjectResultthat produces a Bad Request (400) response.Return type: Microsoft.AspNetCore.Mvc.BadRequestObjectResult Returns: The created Microsoft.AspNetCore.Mvc.BadRequestObjectResultfor the response.public virtual BadRequestObjectResult BadRequest(ModelStateDictionary modelState)
-
BadRequest(System.Object) Creates an
Microsoft.AspNetCore.Mvc.BadRequestObjectResultthat produces a Bad Request (400) response.Return type: Microsoft.AspNetCore.Mvc.BadRequestObjectResult Returns: The created Microsoft.AspNetCore.Mvc.BadRequestObjectResultfor 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.ChallengeResultfor the response.public virtual ChallengeResult Challenge()
-
Challenge(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) Creates a
Microsoft.AspNetCore.Mvc.ChallengeResultwith the specified <em>properties</em>.Arguments: properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) – Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the authentication challenge.Return type: Microsoft.AspNetCore.Mvc.ChallengeResult Returns: The created Microsoft.AspNetCore.Mvc.ChallengeResultfor the response.public virtual ChallengeResult Challenge(AuthenticationProperties properties)
-
Challenge(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[]) Creates a
Microsoft.AspNetCore.Mvc.ChallengeResultwith the specified specified authentication schemes and <em>properties</em>.Arguments: - properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the authentication challenge. - authenticationSchemes (System.String<System.String>[]) – The authentication schemes to challenge.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.ChallengeResultfor the response.public virtual ChallengeResult Challenge(AuthenticationProperties properties, params string[] authenticationSchemes)
- properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
-
Challenge(System.String[]) Creates a
Microsoft.AspNetCore.Mvc.ChallengeResultwith 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.ChallengeResultfor the response.public virtual ChallengeResult Challenge(params string[] authenticationSchemes)
-
Content(System.String)¶ Creates a
Microsoft.AspNetCore.Mvc.ContentResultobject 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.ContentResultobject for the response.public virtual ContentResult Content(string content)
-
Content(System.String, Microsoft.Net.Http.Headers.MediaTypeHeaderValue) Creates a
Microsoft.AspNetCore.Mvc.ContentResultobject by specifying a <em>content</em> string and a <em>contentType</em>.Arguments: - content (System.String) – The content to write to the response.
- contentType (Microsoft.Net.Http.Headers.MediaTypeHeaderValue) – The content type (MIME type).
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.ContentResultobject for the response.public virtual ContentResult Content(string content, MediaTypeHeaderValue contentType)
-
Content(System.String, System.String) Creates a
Microsoft.AspNetCore.Mvc.ContentResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.ContentResultobject for the response.public virtual ContentResult Content(string content, string contentType)
-
Content(System.String, System.String, System.Text.Encoding) Creates a
Microsoft.AspNetCore.Mvc.ContentResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.ContentResultobject for the response.public virtual ContentResult Content(string content, string contentType, Encoding contentEncoding)
-
Created(System.String, System.Object)¶ Creates a
Microsoft.AspNetCore.Mvc.CreatedResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedResultfor the response.public virtual CreatedResult Created(string uri, object value)
-
Created(System.Uri, System.Object) Creates a
Microsoft.AspNetCore.Mvc.CreatedResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedResultfor the response.public virtual CreatedResult Created(Uri uri, object value)
-
CreatedAtAction(System.String, System.Object)¶ Creates a
Microsoft.AspNetCore.Mvc.CreatedAtActionResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtActionResultfor the response.public virtual CreatedAtActionResult CreatedAtAction(string actionName, object value)
-
CreatedAtAction(System.String, System.Object, System.Object) Creates a
Microsoft.AspNetCore.Mvc.CreatedAtActionResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtActionResultfor 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.CreatedAtActionResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtActionResultfor the response.public virtual CreatedAtActionResult CreatedAtAction(string actionName, string controllerName, object routeValues, object value)
-
CreatedAtRoute(System.Object, System.Object)¶ Creates a
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultfor the response.public virtual CreatedAtRouteResult CreatedAtRoute(object routeValues, object value)
-
CreatedAtRoute(System.String, System.Object) Creates a
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultfor the response.public virtual CreatedAtRouteResult CreatedAtRoute(string routeName, object value)
-
CreatedAtRoute(System.String, System.Object, System.Object) Creates a
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultobject 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: Returns: The created
Microsoft.AspNetCore.Mvc.CreatedAtRouteResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.FileContentResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.FileContentResultfor 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.Streamwith the contents of the file. - contentType (System.String) – The Content-Type of the file.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.FileStreamResultfor the response.public virtual FileStreamResult File(Stream fileStream, string contentType)
- fileStream (System.IO.Stream) – The
-
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.Streamwith the contents of the file. - contentType (System.String) – The Content-Type of the file.
- fileDownloadName (System.String) – The suggested file name.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.FileStreamResultfor the response.public virtual FileStreamResult File(Stream fileStream, string contentType, string fileDownloadName)
- fileStream (System.IO.Stream) – The
-
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: Returns: The created
Microsoft.AspNetCore.Mvc.VirtualFileResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.VirtualFileResultfor 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.ForbidResultfor the response.public virtual ForbidResult Forbid()
-
Forbid(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) Creates a
Microsoft.AspNetCore.Mvc.ForbidResultwith the specified <em>properties</em>.Arguments: properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) – Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the authentication challenge.Return type: Microsoft.AspNetCore.Mvc.ForbidResult Returns: The created Microsoft.AspNetCore.Mvc.ForbidResultfor the response.public virtual ForbidResult Forbid(AuthenticationProperties properties)
-
Forbid(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[]) Creates a
Microsoft.AspNetCore.Mvc.ForbidResultwith the specified specified authentication schemes and <em>properties</em>.Arguments: - properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the authentication challenge. - authenticationSchemes (System.String<System.String>[]) – The authentication schemes to challenge.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.ForbidResultfor the response.public virtual ForbidResult Forbid(AuthenticationProperties properties, params string[] authenticationSchemes)
- properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
-
Forbid(System.String[]) Creates a
Microsoft.AspNetCore.Mvc.ForbidResultwith 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.ForbidResultfor the response.public virtual ForbidResult Forbid(params string[] authenticationSchemes)
-
LocalRedirect(System.String)¶ Creates a
Microsoft.AspNetCore.Mvc.LocalRedirectResultobject 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.LocalRedirectResultfor the response.public virtual LocalRedirectResult LocalRedirect(string localUrl)
-
LocalRedirectPermanent(System.String)¶ Creates a
Microsoft.AspNetCore.Mvc.LocalRedirectResultobject withMicrosoft.AspNetCore.Mvc.LocalRedirectResult.Permanentset 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.LocalRedirectResultfor the response.public virtual LocalRedirectResult LocalRedirectPermanent(string localUrl)
-
NoContent()¶ Creates a
Microsoft.AspNetCore.Mvc.NoContentResultobject that produces an empty No Content (204) response.Return type: Microsoft.AspNetCore.Mvc.NoContentResult Returns: The created Microsoft.AspNetCore.Mvc.NoContentResultobject for the response.public virtual NoContentResult NoContent()
-
NotFound()¶ Creates an
Microsoft.AspNetCore.Mvc.NotFoundResultthat produces a Not Found (404) response.Return type: Microsoft.AspNetCore.Mvc.NotFoundResult Returns: The created Microsoft.AspNetCore.Mvc.NotFoundResultfor the response.public virtual NotFoundResult NotFound()
-
NotFound(System.Object) Creates an
Microsoft.AspNetCore.Mvc.NotFoundObjectResultthat produces a Not Found (404) response.Return type: Microsoft.AspNetCore.Mvc.NotFoundObjectResult Returns: The created Microsoft.AspNetCore.Mvc.NotFoundObjectResultfor the response.public virtual NotFoundObjectResult NotFound(object value)
-
Ok()¶ Creates a
Microsoft.AspNetCore.Mvc.OkResultobject that produces an empty OK (200) response.Return type: Microsoft.AspNetCore.Mvc.OkResult Returns: The created Microsoft.AspNetCore.Mvc.OkResultfor the response.public virtual OkResult Ok()
-
Ok(System.Object) Creates an
Microsoft.AspNetCore.Mvc.OkObjectResultobject 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.OkObjectResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.PhysicalFileResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.PhysicalFileResultfor the response.public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, string fileDownloadName)
-
Redirect(System.String)¶ Creates a
Microsoft.AspNetCore.Mvc.RedirectResultobject 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.RedirectResultfor the response.public virtual RedirectResult Redirect(string url)
-
RedirectPermanent(System.String)¶ Creates a
Microsoft.AspNetCore.Mvc.RedirectResultobject withMicrosoft.AspNetCore.Mvc.RedirectResult.Permanentset 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.RedirectResultfor 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.RedirectToActionResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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.Permanentset 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.RedirectToActionResultfor the response.public virtual RedirectToActionResult RedirectToActionPermanent(string actionName)
-
RedirectToActionPermanent(System.String, System.Object) Redirects to the specified action with
Microsoft.AspNetCore.Mvc.RedirectToActionResult.Permanentset 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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.Permanentset 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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.Permanentset 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToActionResultfor 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.RedirectToRouteResultfor 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.RedirectToRouteResultfor 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToRouteResultfor the response.public virtual RedirectToRouteResult RedirectToRoute(string routeName, object routeValues)
-
RedirectToRoutePermanent(System.Object)¶ Redirects to the specified route with
Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanentset 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.RedirectToRouteResultfor the response.public virtual RedirectToRouteResult RedirectToRoutePermanent(object routeValues)
-
RedirectToRoutePermanent(System.String) Redirects to the specified route with
Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanentset 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.RedirectToRouteResultfor the response.public virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName)
-
RedirectToRoutePermanent(System.String, System.Object) Redirects to the specified route with
Microsoft.AspNetCore.Mvc.RedirectToRouteResult.Permanentset 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: Returns: The created
Microsoft.AspNetCore.Mvc.RedirectToRouteResultfor 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.SignInResultwith the specified specified authentication scheme and <em>properties</em>.Arguments: - principal (System.Security.Claims.ClaimsPrincipal) – The
System.Security.Claims.ClaimsPrincipalcontaining the user claims. - properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the sign-in operation. - authenticationScheme (System.String) – The authentication scheme to use for the sign-in operation.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.SignInResultfor the response.public virtual SignInResult SignIn(ClaimsPrincipal principal, AuthenticationProperties properties, string authenticationScheme)
- principal (System.Security.Claims.ClaimsPrincipal) – The
-
SignIn(System.Security.Claims.ClaimsPrincipal, System.String) Creates a
Microsoft.AspNetCore.Mvc.SignInResultwith the specified authentication scheme.Arguments: - principal (System.Security.Claims.ClaimsPrincipal) – The
System.Security.Claims.ClaimsPrincipalcontaining the user claims. - authenticationScheme (System.String) – The authentication scheme to use for the sign-in operation.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.SignInResultfor the response.public virtual SignInResult SignIn(ClaimsPrincipal principal, string authenticationScheme)
- principal (System.Security.Claims.ClaimsPrincipal) – The
-
SignOut(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties, System.String[])¶ Creates a
Microsoft.AspNetCore.Mvc.SignOutResultwith the specified specified authentication schemes and <em>properties</em>.Arguments: - properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
Microsoft.AspNetCore.Http.Authentication.AuthenticationPropertiesused to perform the sign-out operation. - authenticationSchemes (System.String<System.String>[]) – The authentication scheme to use for the sign-out operation.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.SignOutResultfor the response.public virtual SignOutResult SignOut(AuthenticationProperties properties, params string[] authenticationSchemes)
- properties (Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties) –
-
SignOut(System.String[]) Creates a
Microsoft.AspNetCore.Mvc.SignOutResultwith 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.SignOutResultfor the response.public virtual SignOutResult SignOut(params string[] authenticationSchemes)
-
StatusCode(System.Int32)¶ Creates a
Microsoft.AspNetCore.Mvc.StatusCodeResultobject 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.StatusCodeResultobject for the response.public virtual StatusCodeResult StatusCode(int statusCode)
-
StatusCode(System.Int32, System.Object) Creates a
Microsoft.AspNetCore.Mvc.ObjectResultobject by specifying a <em>statusCode</em> and <em>value</em>Arguments: - statusCode (System.Int32) – The status code to set on the response.
- value (System.Object) – The value to set on the
Microsoft.AspNetCore.Mvc.ObjectResult.
Return type: Returns: The created
Microsoft.AspNetCore.Mvc.ObjectResultobject 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.IValueProviderand 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.Taskthat 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.IValueProviderused 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.Taskthat 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.Taskthat 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.IValueProviderand 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.
Return type: System.Threading.Tasks.Task<System.Boolean>
Returns: A
System.Threading.Tasks.Taskthat 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: - 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.IValueProviderused for looking up values.
Return type: System.Threading.Tasks.Task<System.Boolean>
Returns: A
System.Threading.Tasks.Taskthat 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: - 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.IValueProviderused 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.Taskthat 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.IValueProviderused 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.Taskthat 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.IValueProviderand 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.Taskthat 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.IValueProviderand 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.Taskthat 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.ModelStateis valid; <code>false</code> otherwise.public virtual bool TryValidateModel(object model)
-
TryValidateModel(System.Object, System.String) Validates the specified <em>model</em> instance.
Arguments: - model (System.Object) – The model to validate.
- prefix (System.String) – The key to use when looking up information in
Microsoft.AspNetCore.Mvc.ControllerBase.ModelState.
Return type: System.Boolean
Returns: <code>true</code> if the
Microsoft.AspNetCore.Mvc.ControllerBase.ModelStateis valid;<code>false</code> otherwise.public virtual bool TryValidateModel(object model, string prefix)
Creates an
Microsoft.AspNetCore.Mvc.UnauthorizedResultthat produces an Unauthorized (401) response.Return type: Microsoft.AspNetCore.Mvc.UnauthorizedResult Returns: The created Microsoft.AspNetCore.Mvc.UnauthorizedResultfor 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.HttpContextfor 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.ModelStateDictionarythat 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.HttpRequestfor the executing action.Return type: Microsoft.AspNetCore.Http.HttpRequest public HttpRequest Request { get; }
-
Microsoft.AspNetCore.Mvc.ControllerBase.Response¶ Gets the
Microsoft.AspNetCore.Http.HttpResponsefor the executing action.Return type: Microsoft.AspNetCore.Http.HttpResponse public HttpResponse Response { get; }
-
Microsoft.AspNetCore.Mvc.ControllerBase.RouteData¶ Gets the
Microsoft.AspNetCore.Routing.RouteDatafor 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.ClaimsPrincipalfor user associated with the executing action.Return type: System.Security.Claims.ClaimsPrincipal public ClaimsPrincipal User { get; }
-