Controller Class

Summary

Base class for an MVC controller.

Syntax

public abstract class Controller : IActionFilter, IAsyncActionFilter, IFilter, IDisposable

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.Controller

Properties

ActionContext()

Gets or sets the [Microsoft.AspNet.Mvc.ActionContext]() object.

Return type:Microsoft.AspNet.Mvc.ActionContext
public ActionContext ActionContext { get; set; }
BindingContext()

Gets or sets the [Microsoft.AspNet.Mvc.ActionBindingContext]().

Return type:Microsoft.AspNet.Mvc.ActionBindingContext
public ActionBindingContext BindingContext { get; set; }
Context()

Gets the @!:HttpContext- for the executing action.

Return type:HttpContext
public HttpContext Context { get; }
MetadataProvider()

Gets or sets the [Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider]().

Return type:Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider
public IModelMetadataProvider MetadataProvider { get; set; }
ModelState()

Gets the [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() that contains the state of the model and of model-binding validation.

Return type:Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary
public ModelStateDictionary ModelState { get; }
ObjectValidator()
Return type:Microsoft.AspNet.Mvc.ModelBinding.Validation.IObjectModelValidator
public IObjectModelValidator ObjectValidator { get; set; }
Request()

Gets the @!:HttpRequest- for the executing action.

Return type:HttpRequest
public HttpRequest Request { get; }
Resolver()

Gets the request-specific [System.IServiceProvider]().

Return type:System.IServiceProvider
public IServiceProvider Resolver { get; }
Response()

Gets the @!:HttpResponse- for the executing action.

Return type:HttpResponse
public HttpResponse Response { get; }
RouteData()

Gets the @!:AspNet.Routing.RouteData- for the executing action.

Return type:RouteData
public RouteData RouteData { get; }
TempData()

Gets or sets [Microsoft.AspNet.Mvc.ITempDataDictionary]() used by [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml).

Return type:Microsoft.AspNet.Mvc.ITempDataDictionary
public ITempDataDictionary TempData { get; set; }
Url()

Gets or sets the [Microsoft.AspNet.Mvc.IUrlHelper]().

Return type:Microsoft.AspNet.Mvc.IUrlHelper
public IUrlHelper Url { get; set; }
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; }
ViewBag()

Gets the dynamic view bag.

Return type:dynamic
public ViewBag { get; }
ViewData()

Gets or sets [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) used by [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) and [Microsoft.AspNet.Mvc.Controller.ViewBag](Microsoft.AspNet.Mvc.Controller.yml).

Return type:Microsoft.AspNet.Mvc.ViewDataDictionary
public ViewDataDictionary ViewData { get; set; }

Methods

Content(System.String)

Creates a [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object by specifying a <paramref name=”content” /> string.

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

Microsoft.AspNet.Mvc.ContentResult

Returns:

The created [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object for the response.

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

Creates a [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object by specifying a <paramref name=”content” /> string and a <paramref name=”contentType” />.

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

Microsoft.AspNet.Mvc.ContentResult

Returns:

The created [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object for the response.

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

Creates a [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object by specifying a <paramref name=”content” /> 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.AspNet.Mvc.ContentResult

Returns:

The created [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object for the response.

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

Creates a [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object by specifying a <paramref name=”content” /> string, a <paramref name=”contentType” />, and <paramref name=”contentEncoding” />.

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.AspNet.Mvc.ContentResult

Returns:

The created [Microsoft.AspNet.Mvc.ContentResult](Microsoft.AspNet.Mvc.ContentResult.yml) object for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedResult](Microsoft.AspNet.Mvc.CreatedResult.yml) 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.AspNet.Mvc.CreatedResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedResult](Microsoft.AspNet.Mvc.CreatedResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedResult](Microsoft.AspNet.Mvc.CreatedResult.yml) 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.AspNet.Mvc.CreatedResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedResult](Microsoft.AspNet.Mvc.CreatedResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedAtActionResult](Microsoft.AspNet.Mvc.CreatedAtActionResult.yml) 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.AspNet.Mvc.CreatedAtActionResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedAtActionResult](Microsoft.AspNet.Mvc.CreatedAtActionResult.yml) 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.AspNet.Mvc.CreatedAtActionResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) 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.AspNet.Mvc.CreatedAtActionResult](Microsoft.AspNet.Mvc.CreatedAtActionResult.yml) 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.AspNet.Mvc.CreatedAtActionResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) 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.AspNet.Mvc.CreatedAtRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) 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.AspNet.Mvc.CreatedAtRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) for the response.

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

Creates a [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) 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.AspNet.Mvc.CreatedAtRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.CreatedAtRouteResult](Microsoft.AspNet.Mvc.CreatedAtRouteResult.yml) for the response.

public virtual CreatedAtRouteResult CreatedAtRoute(string routeName, object routeValues, object value)
Microsoft.AspNet.Mvc.Controller.Dispose()
public void Dispose()
Dispose(System.Boolean)

Releases all resources currently used by this [Microsoft.AspNet.Mvc.Controller](Microsoft.AspNet.Mvc.Controller.yml) instance.

Arguments:
  • disposing (System.Boolean) – <c>true</c> if this method is being invoked by the [Microsoft.AspNet.Mvc.Controller.Dispose](Microsoft.AspNet.Mvc.Controller.yml) method, otherwise <c>false</c>.
protected virtual void Dispose(bool disposing)
File(System.Byte[], System.String)

Returns a file with the specified <paramref name=”fileContents” /> as content and the specified <paramref name=”contentType” /> as the Content-Type.

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

Microsoft.AspNet.Mvc.FileContentResult

Returns:

The created [Microsoft.AspNet.Mvc.FileContentResult](Microsoft.AspNet.Mvc.FileContentResult.yml) for the response.

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

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

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

Microsoft.AspNet.Mvc.FileContentResult

Returns:

The created [Microsoft.AspNet.Mvc.FileContentResult](Microsoft.AspNet.Mvc.FileContentResult.yml) 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 <paramref name=”fileStream” /> with the specified <paramref name=”contentType” /> 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.AspNet.Mvc.FileStreamResult

Returns:

The created [Microsoft.AspNet.Mvc.FileStreamResult](Microsoft.AspNet.Mvc.FileStreamResult.yml) 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 <paramref name=”fileStream” /> with the specified <paramref name=”contentType” /> as the Content-Type and the specified <paramref name=”fileDownloadName” /> 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.AspNet.Mvc.FileStreamResult

Returns:

The created [Microsoft.AspNet.Mvc.FileStreamResult](Microsoft.AspNet.Mvc.FileStreamResult.yml) for the response.

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

Returns the file specified by <paramref name=”fileName” /> with the specified <paramref name=”contentType” /> as the Content-Type.

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

Microsoft.AspNet.Mvc.FilePathResult

Returns:

The created [Microsoft.AspNet.Mvc.FilePathResult](Microsoft.AspNet.Mvc.FilePathResult.yml) for the response.

public virtual FilePathResult File(string fileName, string contentType)
File(System.String, System.String, System.String)

Returns the file specified by <paramref name=”fileName” /> with the specified <paramref name=”contentType” /> as the Content-Type and the specified <paramref name=”fileDownloadName” /> as the suggested file name.

Arguments:
  • fileName (System.String) – 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.AspNet.Mvc.FilePathResult

Returns:

The created [Microsoft.AspNet.Mvc.FilePathResult](Microsoft.AspNet.Mvc.FilePathResult.yml) for the response.

public virtual FilePathResult File(string fileName, string contentType, string fileDownloadName)
Microsoft.AspNet.Mvc.Controller.HttpBadRequest()

Creates an [Microsoft.AspNet.Mvc.BadRequestResult](Microsoft.AspNet.Mvc.BadRequestResult.yml) that produces a Bad Request (400) response.

Return type:Microsoft.AspNet.Mvc.BadRequestResult
Returns:The created [Microsoft.AspNet.Mvc.BadRequestResult](Microsoft.AspNet.Mvc.BadRequestResult.yml) for the response.
public virtual BadRequestResult HttpBadRequest()
HttpBadRequest(Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary)

Creates an [Microsoft.AspNet.Mvc.BadRequestObjectResult](Microsoft.AspNet.Mvc.BadRequestObjectResult.yml) that produces a Bad Request (400) response.

Arguments:
Return type:

Microsoft.AspNet.Mvc.BadRequestObjectResult

Returns:

The created [Microsoft.AspNet.Mvc.BadRequestObjectResult](Microsoft.AspNet.Mvc.BadRequestObjectResult.yml) for the response.

public virtual BadRequestObjectResult HttpBadRequest(ModelStateDictionary modelState)
HttpBadRequest(System.Object)

Creates an [Microsoft.AspNet.Mvc.BadRequestObjectResult](Microsoft.AspNet.Mvc.BadRequestObjectResult.yml) that produces a Bad Request (400) response.

Arguments:
  • error (System.Object) –
Return type:

Microsoft.AspNet.Mvc.BadRequestObjectResult

Returns:

The created [Microsoft.AspNet.Mvc.BadRequestObjectResult](Microsoft.AspNet.Mvc.BadRequestObjectResult.yml) for the response.

public virtual BadRequestObjectResult HttpBadRequest(object error)
Microsoft.AspNet.Mvc.Controller.HttpNotFound()

Creates an [Microsoft.AspNet.Mvc.HttpNotFoundResult](Microsoft.AspNet.Mvc.HttpNotFoundResult.yml) that produces a Not Found (404) response.

Return type:Microsoft.AspNet.Mvc.HttpNotFoundResult
Returns:The created [Microsoft.AspNet.Mvc.HttpNotFoundResult](Microsoft.AspNet.Mvc.HttpNotFoundResult.yml) for the response.
public virtual HttpNotFoundResult HttpNotFound()
HttpNotFound(System.Object)

Creates an [Microsoft.AspNet.Mvc.HttpNotFoundObjectResult](Microsoft.AspNet.Mvc.HttpNotFoundObjectResult.yml) that produces a Not Found (404) response.

Arguments:
  • value (System.Object) –
Return type:

Microsoft.AspNet.Mvc.HttpNotFoundObjectResult

Returns:

The created [Microsoft.AspNet.Mvc.HttpNotFoundObjectResult](Microsoft.AspNet.Mvc.HttpNotFoundObjectResult.yml) for the response.

public virtual HttpNotFoundObjectResult HttpNotFound(object value)
Microsoft.AspNet.Mvc.Controller.HttpUnauthorized()

Creates an [Microsoft.AspNet.Mvc.HttpUnauthorizedResult](Microsoft.AspNet.Mvc.HttpUnauthorizedResult.yml) that produces an Unauthorized (401) response.

Return type:Microsoft.AspNet.Mvc.HttpUnauthorizedResult
Returns:The created [Microsoft.AspNet.Mvc.HttpUnauthorizedResult](Microsoft.AspNet.Mvc.HttpUnauthorizedResult.yml) for the response.
public virtual HttpUnauthorizedResult HttpUnauthorized()
Json(System.Object)

Creates a [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) object that serializes the specified <paramref name=”data” /> object to JSON.

Arguments:
  • data (System.Object) – The object to serialize.
Return type:

Microsoft.AspNet.Mvc.JsonResult

Returns:

The created [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) that serializes the specified <paramref name=”data” /> to JSON format for the response.

public virtual JsonResult Json(object data)
Json(System.Object, JsonSerializerSettings)

Creates a [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) object that serializes the specified <paramref name=”data” /> object to JSON.

Arguments:
  • data (System.Object) – The object to serialize.
  • serializerSettings (JsonSerializerSettings) – The @!:JsonSerializerSettings- to be used by the formatter.
Return type:

Microsoft.AspNet.Mvc.JsonResult

Returns:

The created [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) that serializes the specified <paramref name=”data” /> as JSON format for the response.

public virtual JsonResult Json(object data, JsonSerializerSettings serializerSettings)
OnActionExecuted(Microsoft.AspNet.Mvc.ActionExecutedContext)

Called after the action method is invoked.

Arguments:
public virtual void OnActionExecuted(ActionExecutedContext context)
OnActionExecuting(Microsoft.AspNet.Mvc.ActionExecutingContext)

Called before the action method is invoked.

Arguments:
public virtual void OnActionExecuting(ActionExecutingContext context)
OnActionExecutionAsync(Microsoft.AspNet.Mvc.ActionExecutingContext, Microsoft.AspNet.Mvc.ActionExecutionDelegate)

Called before the action method is invoked.

Arguments:
  • context (Microsoft.AspNet.Mvc.ActionExecutingContext) – The action executing context.
  • next (Microsoft.AspNet.Mvc.ActionExecutionDelegate) – The [Microsoft.AspNet.Mvc.ActionExecutionDelegate]() to execute. Invoke this delegate in the body of [Microsoft.AspNet.Mvc.Controller.OnActionExecutionAsync(Microsoft.AspNet.Mvc.ActionExecutingContext,Microsoft.AspNet.Mvc.ActionExecutionDelegate)](Microsoft.AspNet.Mvc.Controller.yml) to continue execution of the action.
Return type:

System.Threading.Tasks.Task

Returns:

A [System.Threading.Tasks.Task]() instance.

public virtual Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
Microsoft.AspNet.Mvc.Controller.PartialView()

Creates a [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object that renders a partial view to the response.

Return type:Microsoft.AspNet.Mvc.PartialViewResult
Returns:The created [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object for the response.
public virtual PartialViewResult PartialView()
PartialView(System.Object)

Creates a [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object by specifying a <paramref name=”model” /> to be rendered by the partial view.

Arguments:
  • model (System.Object) – The model that is rendered by the partial view.
Return type:

Microsoft.AspNet.Mvc.PartialViewResult

Returns:

The created [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object for the response.

public virtual PartialViewResult PartialView(object model)
PartialView(System.String)

Creates a [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object by specifying a <paramref name=”viewName” />.

Arguments:
  • viewName (System.String) – The name of the view that is rendered to the response.
Return type:

Microsoft.AspNet.Mvc.PartialViewResult

Returns:

The created [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object for the response.

public virtual PartialViewResult PartialView(string viewName)
PartialView(System.String, System.Object)

Creates a [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object by specifying a <paramref name=”viewName” /> and the <paramref name=”model” /> to be rendered by the partial view.

Arguments:
  • viewName (System.String) – The name of the partial view that is rendered to the response.
  • model (System.Object) – The model that is rendered by the partial view.
Return type:

Microsoft.AspNet.Mvc.PartialViewResult

Returns:

The created [Microsoft.AspNet.Mvc.PartialViewResult](Microsoft.AspNet.Mvc.PartialViewResult.yml) object for the response.

public virtual PartialViewResult PartialView(string viewName, object model)
Redirect(System.String)

Creates a [Microsoft.AspNet.Mvc.RedirectResult](Microsoft.AspNet.Mvc.RedirectResult.yml) object that redirects to the specified <paramref name=”url” />.

Arguments:
  • url (System.String) – The URL to redirect to.
Return type:

Microsoft.AspNet.Mvc.RedirectResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectResult](Microsoft.AspNet.Mvc.RedirectResult.yml) for the response.

public virtual RedirectResult Redirect(string url)
RedirectPermanent(System.String)

Creates a [Microsoft.AspNet.Mvc.RedirectResult](Microsoft.AspNet.Mvc.RedirectResult.yml) object with [Microsoft.AspNet.Mvc.RedirectResult.Permanent](Microsoft.AspNet.Mvc.RedirectResult.yml) set to true using the specified <paramref name=”url” />.

Arguments:
  • url (System.String) – The URL to redirect to.
Return type:

Microsoft.AspNet.Mvc.RedirectResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectResult](Microsoft.AspNet.Mvc.RedirectResult.yml) for the response.

public virtual RedirectResult RedirectPermanent(string url)
RedirectToAction(System.String)

Redirects to the specified action using the <paramref name=”actionName” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified action using the <paramref name=”actionName” /> and <paramref name=”routeValues” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified action using the <paramref name=”actionName” /> and the <paramref name=”controllerName” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) 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 <paramref name=”actionName” />,

<paramref name=”controllerName” />, and <paramref name=”routeValues” />.

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.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified action with [Microsoft.AspNet.Mvc.RedirectToActionResult.Permanent](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) set to true using the specified <paramref name=”actionName” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified action with [Microsoft.AspNet.Mvc.RedirectToActionResult.Permanent](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) set to true using the specified <paramref name=”actionName” /> and <paramref name=”routeValues” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified action with [Microsoft.AspNet.Mvc.RedirectToActionResult.Permanent](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) set to true using the specified <paramref name=”actionName” /> and <paramref name=”controllerName” />.

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

Microsoft.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) 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.AspNet.Mvc.RedirectToActionResult.Permanent](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) set to true using the specified <paramref name=”actionName” />, <paramref name=”controllerName” />, and <paramref name=”routeValues” />.

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.AspNet.Mvc.RedirectToActionResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToActionResult](Microsoft.AspNet.Mvc.RedirectToActionResult.yml) for the response.

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

Redirects to the specified route using the specified <paramref name=”routeValues” />.

Arguments:
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

public virtual RedirectToRouteResult RedirectToRoute(object routeValues)
RedirectToRoute(System.String)

Redirects to the specified route using the specified <paramref name=”routeName” />.

Arguments:
  • routeName (System.String) – The name of the route.
Return type:

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

public virtual RedirectToRouteResult RedirectToRoute(string routeName)
RedirectToRoute(System.String, System.Object)

Redirects to the specified route using the specified <paramref name=”routeName” /> and <paramref name=”routeValues” />.

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

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

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

Redirects to the specified route with [Microsoft.AspNet.Mvc.RedirectToRouteResult.Permanent](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) set to true using the specified <paramref name=”routeValues” />.

Arguments:
  • routeValues (System.Object) – The parameters for a route.
Return type:

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

public virtual RedirectToRouteResult RedirectToRoutePermanent(object routeValues)
RedirectToRoutePermanent(System.String)

Redirects to the specified route with [Microsoft.AspNet.Mvc.RedirectToRouteResult.Permanent](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) set to true using the specified <paramref name=”routeName” />.

Arguments:
  • routeName (System.String) – The name of the route.
Return type:

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

public virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName)
RedirectToRoutePermanent(System.String, System.Object)

Redirects to the specified route with [Microsoft.AspNet.Mvc.RedirectToRouteResult.Permanent](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) set to true using the specified <paramref name=”routeName” /> and <paramref name=”routeValues” />.

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

Microsoft.AspNet.Mvc.RedirectToRouteResult

Returns:

The created [Microsoft.AspNet.Mvc.RedirectToRouteResult](Microsoft.AspNet.Mvc.RedirectToRouteResult.yml) for the response.

public virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName, object routeValues)
TryUpdateModelAsync(System.Object, System.Type, System.String)

Updates the specified <paramref name=”model” /> instance using values from the controller’s current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() and a <paramref name=”prefix” />.

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.AspNet.Mvc.ModelBinding.IValueProvider]()
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

A [System.Threading.Tasks.Task]() that on completion returns <c>true</c> if the update is successful

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

Updates the specified <paramref name=”model” /> instance using the <paramref name=”valueProvider” /> and a

<paramref name=”prefix” />.

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 <paramref name=”valueProvider” />
  • valueProvider (Microsoft.AspNet.Mvc.ModelBinding.IValueProvider) – The [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() used for looking up values.
  • predicate (System.Func{Microsoft.AspNet.Mvc.ModelBinding.ModelBindingContext,System.String,System.Boolean}) – 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 <c>true</c> if the update is successful

public Task<bool> TryUpdateModelAsync(object model, Type modelType, string prefix, IValueProvider valueProvider, Func<ModelBindingContext, string, bool> predicate)
Microsoft.AspNet.Mvc.Controller.TryUpdateModelAsync<TModel>(TModel)

Updates the specified <paramref name=”model” /> instance using values from the controller’s current [Microsoft.AspNet.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 <c>true</c> if the update is successful

public virtual Task<bool> TryUpdateModelAsync<TModel>(TModel model)where TModel : class
Microsoft.AspNet.Mvc.Controller.TryUpdateModelAsync<TModel>(TModel, System.String)

Updates the specified <paramref name=”model” /> instance using values from the controller’s current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() and a <paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]()
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

A [System.Threading.Tasks.Task]() that on completion returns <c>true</c> if the update is successful

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

Updates the specified <paramref name=”model” /> instance using the <paramref name=”valueProvider” /> and a

<paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the <paramref name=”valueProvider” />.
  • valueProvider (Microsoft.AspNet.Mvc.ModelBinding.IValueProvider) – The [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() used for looking up values.
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

A [System.Threading.Tasks.Task]() that on completion returns <c>true</c> if the update is successful

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

Updates the specified <paramref name=”model” /> instance using the <paramref name=”valueProvider” /> and a

<paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the <paramref name=”valueProvider” />
  • valueProvider (Microsoft.AspNet.Mvc.ModelBinding.IValueProvider) – The [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() used for looking up values.
  • predicate (System.Func{Microsoft.AspNet.Mvc.ModelBinding.ModelBindingContext,System.String,System.Boolean}) – 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 <c>true</c> if the update is successful

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

Updates the specified <paramref name=”model” /> instance using the <paramref name=”valueProvider” /> and a

<paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the <paramref name=”valueProvider” />
  • valueProvider (Microsoft.AspNet.Mvc.ModelBinding.IValueProvider) – The [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() used for looking up values.
  • includeExpressions (System.Linq.Expressions.Expression{System.Func{{TModel},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 <c>true</c> 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
Microsoft.AspNet.Mvc.Controller.TryUpdateModelAsync<TModel>(TModel, System.String, System.Func<Microsoft.AspNet.Mvc.ModelBinding.ModelBindingContext, System.String, System.Boolean>)

Updates the specified <paramref name=”model” /> instance using values from the controller’s current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() and a <paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]().
  • predicate (System.Func{Microsoft.AspNet.Mvc.ModelBinding.ModelBindingContext,System.String,System.Boolean}) – 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 <c>true</c> if the update is successful

public Task<bool> TryUpdateModelAsync<TModel>(TModel model, string prefix, Func<ModelBindingContext, string, bool> predicate)where TModel : class
Microsoft.AspNet.Mvc.Controller.TryUpdateModelAsync<TModel>(TModel, System.String, System.Linq.Expressions.Expression<System.Func<TModel, System.Object>>[])

Updates the specified <paramref name=”model” /> instance using values from the controller’s current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]() and a <paramref name=”prefix” />.

Arguments:
  • model (TModel) – The model instance to update.
  • prefix (System.String) – The prefix to use when looking up values in the current [Microsoft.AspNet.Mvc.ModelBinding.IValueProvider]().
  • includeExpressions (System.Linq.Expressions.Expression{System.Func{{TModel},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 <c>true</c> 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 <paramref name=”model” /> instance.

Arguments:
  • model (System.Object) – The model to validate.
Return type:

System.Boolean

Returns:

<c>true</c> if the [Microsoft.AspNet.Mvc.Controller.ModelState](Microsoft.AspNet.Mvc.Controller.yml) is valid; <c>false</c> otherwise.

public virtual bool TryValidateModel(object model)
TryValidateModel(System.Object, System.String)

Validates the specified <paramref name=”model” /> instance.

Arguments:
  • model (System.Object) – The model to validate.
  • prefix (System.String) – The key to use when looking up information in [Microsoft.AspNet.Mvc.Controller.ModelState](Microsoft.AspNet.Mvc.Controller.yml).
Return type:

System.Boolean

Returns:

<c>true</c> if the [Microsoft.AspNet.Mvc.Controller.ModelState](Microsoft.AspNet.Mvc.Controller.yml) is valid; <c>false</c> otherwise.

public virtual bool TryValidateModel(object model, string prefix)
Microsoft.AspNet.Mvc.Controller.View()

Creates a [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object that renders a view to the response.

Return type:Microsoft.AspNet.Mvc.ViewResult
Returns:The created [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object for the response.
public virtual ViewResult View()
View(System.Object)

Creates a [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object by specifying a <paramref name=”model” /> to be rendered by the view.

Arguments:
  • model (System.Object) – The model that is rendered by the view.
Return type:

Microsoft.AspNet.Mvc.ViewResult

Returns:

The created [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object for the response.

public virtual ViewResult View(object model)
View(System.String)

Creates a [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object by specifying a <paramref name=”viewName” />.

Arguments:
  • viewName (System.String) – The name of the view that is rendered to the response.
Return type:

Microsoft.AspNet.Mvc.ViewResult

Returns:

The created [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object for the response.

public virtual ViewResult View(string viewName)
View(System.String, System.Object)

Creates a [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object by specifying a <paramref name=”viewName” /> and the <paramref name=”model” /> to be rendered by the view.

Arguments:
  • viewName (System.String) – The name of the view that is rendered to the response.
  • model (System.Object) – The model that is rendered by the view.
Return type:

Microsoft.AspNet.Mvc.ViewResult

Returns:

The created [Microsoft.AspNet.Mvc.ViewResult](Microsoft.AspNet.Mvc.ViewResult.yml) object for the response.

public virtual ViewResult View(string viewName, object model)