Table of Contents

Class Controller

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Provides methods that respond to HTTP requests that are made to an ASP.NET MVC Web site.

public abstract class Controller : ControllerBase, IActionFilter, IAuthenticationFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter, IAsyncController, IController, IAsyncManagerContainer
Inheritance
Controller
Implements
Derived
Inherited Members

Constructors

Controller()

Initializes a new instance of the Controller class.

protected Controller()

Properties

ActionInvoker

Gets the action invoker for the controller.

public IActionInvoker ActionInvoker { get; set; }

Property Value

IActionInvoker

The action invoker.

AsyncManager

Provides asynchronous operations.

public AsyncManager AsyncManager { get; }

Property Value

AsyncManager

Returns AsyncManager.

Binders

Gets or sets the binder.

protected ModelBinderDictionary Binders { get; set; }

Property Value

ModelBinderDictionary

The binder.

DisableAsyncSupport

Gets whether to disable the asynchronous support for the controller.

protected virtual bool DisableAsyncSupport { get; }

Property Value

bool

true to disable the asynchronous support for the controller; otherwise, false.

HttpContext

Gets HTTP-specific information about an individual HTTP request.

public HttpContextBase HttpContext { get; }

Property Value

HttpContextBase

The HTTP context.

ModelState

Gets the model state dictionary object that contains the state of the model and of model-binding validation.

public ModelStateDictionary ModelState { get; }

Property Value

ModelStateDictionary

The model state dictionary.

Profile

Gets the HTTP context profile.

public ProfileBase Profile { get; }

Property Value

ProfileBase

The HTTP context profile.

Request

Gets the HttpRequestBase object for the current HTTP request.

public HttpRequestBase Request { get; }

Property Value

HttpRequestBase

The request object.

Resolver

Represents a replaceable dependency resolver providing services. By default, it uses the System.Web.Mvc.DependencyResolver.CurrentCache.

public IDependencyResolver Resolver { get; set; }

Property Value

IDependencyResolver

Response

Gets the HttpResponseBase object for the current HTTP response.

public HttpResponseBase Response { get; }

Property Value

HttpResponseBase

The HttpResponseBase object for the current HTTP response.

RouteData

Gets the route data for the current request.

public RouteData RouteData { get; }

Property Value

RouteData

The route data.

Server

Gets the HttpServerUtilityBase object that provides methods that are used during Web request processing.

public HttpServerUtilityBase Server { get; }

Property Value

HttpServerUtilityBase

The HTTP server object.

Session

Gets the HttpSessionStateBase object for the current HTTP request.

public HttpSessionStateBase Session { get; }

Property Value

HttpSessionStateBase

The HTTP session-state object for the current HTTP request.

TempDataProvider

Gets the temporary-data provider object that is used to store data for the next request.

public ITempDataProvider TempDataProvider { get; set; }

Property Value

ITempDataProvider

The temporary-data provider.

Url

Gets the URL helper object that is used to generate URLs by using routing.

public UrlHelper Url { get; set; }

Property Value

UrlHelper

The URL helper object.

User

Gets the user security information for the current HTTP request.

public IPrincipal User { get; }

Property Value

IPrincipal

The user security information for the current HTTP request.

ViewEngineCollection

Gets the view engine collection.

public ViewEngineCollection ViewEngineCollection { get; set; }

Property Value

ViewEngineCollection

The view engine collection.

Methods

BeginExecute(RequestContext, AsyncCallback, object)

Begins execution of the specified request context

protected virtual IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)

Parameters

requestContext RequestContext

The request context.

callback AsyncCallback

The asynchronous callback.

state object

The state.

Returns

IAsyncResult

Returns an IAsyncController instance.

BeginExecuteCore(AsyncCallback, object)

Begins to invoke the action in the current controller context.

protected virtual IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)

Parameters

callback AsyncCallback

The callback.

state object

The state.

Returns

IAsyncResult

Returns an IAsyncController instance.

Content(string)

Creates a content result object by using a string.

protected ContentResult Content(string content)

Parameters

content string

The content to write to the response.

Returns

ContentResult

The content result instance.

Content(string, string)

Creates a content result object by using a string and the content type.

protected ContentResult Content(string content, string contentType)

Parameters

content string

The content to write to the response.

contentType string

The content type (MIME type).

Returns

ContentResult

The content result instance.

Content(string, string, Encoding)

Creates a content result object by using a string, the content type, and content encoding.

protected virtual ContentResult Content(string content, string contentType, Encoding contentEncoding)

Parameters

content string

The content to write to the response.

contentType string

The content type (MIME type).

contentEncoding Encoding

The content encoding.

Returns

ContentResult

The content result instance.

CreateActionInvoker()

Creates an action invoker.

protected virtual IActionInvoker CreateActionInvoker()

Returns

IActionInvoker

An action invoker.

CreateTempDataProvider()

Creates a temporary data provider.

protected virtual ITempDataProvider CreateTempDataProvider()

Returns

ITempDataProvider

A temporary data provider.

Dispose()

Releases all resources that are used by the current instance of the Controller class.

public void Dispose()

Dispose(bool)

Releases unmanaged resources and optionally releases managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

EndExecute(IAsyncResult)

Ends the invocation of the action in the current controller context.

protected virtual void EndExecute(IAsyncResult asyncResult)

Parameters

asyncResult IAsyncResult

The asynchronous result.

EndExecuteCore(IAsyncResult)

Ends the execute core.

protected virtual void EndExecuteCore(IAsyncResult asyncResult)

Parameters

asyncResult IAsyncResult

The asynchronous result.

ExecuteCore()

Invokes the action in the current controller context.

protected override void ExecuteCore()

File(byte[], string)

Creates a FileContentResult object by using the file contents and file type.

protected FileContentResult File(byte[] fileContents, string contentType)

Parameters

fileContents byte[]

The binary content to send to the response.

contentType string

The content type (MIME type).

Returns

FileContentResult

The file-content result object.

File(byte[], string, string)

Creates a FileContentResult object by using the file contents, content type, and the destination file name.

protected virtual FileContentResult File(byte[] fileContents, string contentType, string fileDownloadName)

Parameters

fileContents byte[]

The binary content to send to the response.

contentType string

The content type (MIME type).

fileDownloadName string

The file name to use in the file-download dialog box that is displayed in the browser.

Returns

FileContentResult

The file-content result object.

File(Stream, string)

Creates a FileStreamResult object by using the Stream object and content type.

protected FileStreamResult File(Stream fileStream, string contentType)

Parameters

fileStream Stream

The stream to send to the response.

contentType string

The content type (MIME type).

Returns

FileStreamResult

The file-content result object.

File(Stream, string, string)

Creates a FileStreamResult object using the Stream object, the content type, and the target file name.

protected virtual FileStreamResult File(Stream fileStream, string contentType, string fileDownloadName)

Parameters

fileStream Stream

The stream to send to the response.

contentType string

The content type (MIME type)

fileDownloadName string

The file name to use in the file-download dialog box that is displayed in the browser.

Returns

FileStreamResult

The file-stream result object.

File(string, string)

Creates a FilePathResult object by using the file name and the content type.

protected FilePathResult File(string fileName, string contentType)

Parameters

fileName string

The path of the file to send to the response.

contentType string

The content type (MIME type).

Returns

FilePathResult

The file-stream result object.

File(string, string, string)

Creates a FilePathResult object by using the file name, the content type, and the file download name.

protected virtual FilePathResult File(string fileName, string contentType, string fileDownloadName)

Parameters

fileName string

The path of the file to send to the response.

contentType string

The content type (MIME type).

fileDownloadName string

The file name to use in the file-download dialog box that is displayed in the browser.

Returns

FilePathResult

The file-stream result object.

HandleUnknownAction(string)

Called when a request matches this controller, but no method with the specified action name is found in the controller.

protected virtual void HandleUnknownAction(string actionName)

Parameters

actionName string

The name of the attempted action.

HttpNotFound()

Returns an instance of the HttpNotFoundResult class.

protected HttpNotFoundResult HttpNotFound()

Returns

HttpNotFoundResult

An instance of the HttpNotFoundResult class.

HttpNotFound(string)

Returns an instance of the HttpNotFoundResult class.

protected virtual HttpNotFoundResult HttpNotFound(string statusDescription)

Parameters

statusDescription string

The status description.

Returns

HttpNotFoundResult

An instance of the HttpNotFoundResult class.

Initialize(RequestContext)

Initializes data that might not be available when the constructor is called.

protected override void Initialize(RequestContext requestContext)

Parameters

requestContext RequestContext

The HTTP context and route data.

JavaScript(string)

Creates a JavaScriptResult object.

protected virtual JavaScriptResult JavaScript(string script)

Parameters

script string

The JavaScript code to run on the client

Returns

JavaScriptResult

The JavaScriptResult object that writes the script to the response.

Json(object)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON).

protected JsonResult Json(object data)

Parameters

data object

The JavaScript object graph to serialize.

Returns

JsonResult

The JSON result object that serializes the specified object to JSON format. The result object that is prepared by this method is written to the response by the ASP.NET MVC framework when the object is executed.

Json(object, string)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format.

protected JsonResult Json(object data, string contentType)

Parameters

data object

The JavaScript object graph to serialize.

contentType string

The content type (MIME type).

Returns

JsonResult

The JSON result object that serializes the specified object to JSON format.

Json(object, string, Encoding)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format.

protected virtual JsonResult Json(object data, string contentType, Encoding contentEncoding)

Parameters

data object

The JavaScript object graph to serialize.

contentType string

The content type (MIME type).

contentEncoding Encoding

The content encoding.

Returns

JsonResult

The JSON result object that serializes the specified object to JSON format.

Json(object, string, Encoding, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the content type, content encoding, and the JSON request behavior.

protected virtual JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior)

Parameters

data object

The JavaScript object graph to serialize.

contentType string

The content type (MIME type).

contentEncoding Encoding

The content encoding.

behavior JsonRequestBehavior

The JSON request behavior

Returns

JsonResult

The result object that serializes the specified object to JSON format.

Json(object, string, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified content type and JSON request behavior.

protected JsonResult Json(object data, string contentType, JsonRequestBehavior behavior)

Parameters

data object

The JavaScript object graph to serialize.

contentType string

The content type (MIME type).

behavior JsonRequestBehavior

The JSON request behavior

Returns

JsonResult

The result object that serializes the specified object to JSON format.

Json(object, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified JSON request behavior.

protected JsonResult Json(object data, JsonRequestBehavior behavior)

Parameters

data object

The JavaScript object graph to serialize.

behavior JsonRequestBehavior

The JSON request behavior.

Returns

JsonResult

The result object that serializes the specified object to JSON format.

OnActionExecuted(ActionExecutedContext)

Called after the action method is invoked.

protected virtual void OnActionExecuted(ActionExecutedContext filterContext)

Parameters

filterContext ActionExecutedContext

Information about the current request and action.

OnActionExecuting(ActionExecutingContext)

Called before the action method is invoked.

protected virtual void OnActionExecuting(ActionExecutingContext filterContext)

Parameters

filterContext ActionExecutingContext

Information about the current request and action.

OnAuthentication(AuthenticationContext)

Called when authorization occurs.

protected virtual void OnAuthentication(AuthenticationContext filterContext)

Parameters

filterContext AuthenticationContext

Information about the current request and action.

OnAuthenticationChallenge(AuthenticationChallengeContext)

Called when authorization challenge occurs.

protected virtual void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)

Parameters

filterContext AuthenticationChallengeContext

Information about the current request and action.

OnAuthorization(AuthorizationContext)

Called when authorization occurs.

protected virtual void OnAuthorization(AuthorizationContext filterContext)

Parameters

filterContext AuthorizationContext

Information about the current request and action.

OnException(ExceptionContext)

Called when an unhandled exception occurs in the action.

protected virtual void OnException(ExceptionContext filterContext)

Parameters

filterContext ExceptionContext

Information about the current request and action.

OnResultExecuted(ResultExecutedContext)

Called after the action result that is returned by an action method is executed.

protected virtual void OnResultExecuted(ResultExecutedContext filterContext)

Parameters

filterContext ResultExecutedContext

Information about the current request and action result.

OnResultExecuting(ResultExecutingContext)

Called before the action result that is returned by an action method is executed.

protected virtual void OnResultExecuting(ResultExecutingContext filterContext)

Parameters

filterContext ResultExecutingContext

Information about the current request and action result.

PartialView()

Creates a PartialViewResult object that renders a partial view.

protected PartialViewResult PartialView()

Returns

PartialViewResult

A partial-view result object.

PartialView(object)

Creates a PartialViewResult object that renders a partial view, by using the specified model.

protected PartialViewResult PartialView(object model)

Parameters

model object

The model that is rendered by the partial view

Returns

PartialViewResult

A partial-view result object.

PartialView(string)

Creates a PartialViewResult object that renders a partial view, by using the specified view name.

protected PartialViewResult PartialView(string viewName)

Parameters

viewName string

The name of the view that is rendered to the response.

Returns

PartialViewResult

A partial-view result object.

PartialView(string, object)

Creates a PartialViewResult object that renders a partial view, by using the specified view name and model.

protected virtual PartialViewResult PartialView(string viewName, object model)

Parameters

viewName string

The name of the view that is rendered to the response.

model object

The model that is rendered by the partial view

Returns

PartialViewResult

A partial-view result object.

Redirect(string)

Creates a RedirectResult object that redirects to the specified URL.

protected virtual RedirectResult Redirect(string url)

Parameters

url string

The URL to redirect to.

Returns

RedirectResult

The redirect result object.

RedirectPermanent(string)

Returns an instance of the RedirectResult class with the Permanent property set to true.

protected virtual RedirectResult RedirectPermanent(string url)

Parameters

url string

The URL to redirect to.

Returns

RedirectResult

An instance of the RedirectResult class with the Permanent property set to true.

RedirectToAction(string)

Redirects to the specified action using the action name.

protected RedirectToRouteResult RedirectToAction(string actionName)

Parameters

actionName string

The name of the action.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToAction(string, object)

Redirects to the specified action using the action name and route values.

protected RedirectToRouteResult RedirectToAction(string actionName, object routeValues)

Parameters

actionName string

The name of the action.

routeValues object

The parameters for a route.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToAction(string, string)

Redirects to the specified action using the action name and controller name.

protected RedirectToRouteResult RedirectToAction(string actionName, string controllerName)

Parameters

actionName string

The name of the action.

controllerName string

The name of the controller.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToAction(string, string, object)

Redirects to the specified action using the action name, controller name, and route dictionary.

protected RedirectToRouteResult RedirectToAction(string actionName, string controllerName, object routeValues)

Parameters

actionName string

The name of the action.

controllerName string

The name of the controller.

routeValues object

The parameters for a route.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToAction(string, string, RouteValueDictionary)

Redirects to the specified action using the action name, controller name, and route values.

protected virtual RedirectToRouteResult RedirectToAction(string actionName, string controllerName, RouteValueDictionary routeValues)

Parameters

actionName string

The name of the action.

controllerName string

The name of the controller.

routeValues RouteValueDictionary

The parameters for a route.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToAction(string, RouteValueDictionary)

Redirects to the specified action using the action name and route dictionary.

protected RedirectToRouteResult RedirectToAction(string actionName, RouteValueDictionary routeValues)

Parameters

actionName string

The name of the action.

routeValues RouteValueDictionary

The parameters for a route.

Returns

RedirectToRouteResult

The redirect result object.

RedirectToActionPermanent(string)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name.

protected RedirectToRouteResult RedirectToActionPermanent(string actionName)

Parameters

actionName string

The action name.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

RedirectToActionPermanent(string, object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

protected RedirectToRouteResult RedirectToActionPermanent(string actionName, object routeValues)

Parameters

actionName string

The action name.

routeValues object

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

RedirectToActionPermanent(string, string)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and controller name.

protected RedirectToRouteResult RedirectToActionPermanent(string actionName, string controllerName)

Parameters

actionName string

The action name.

controllerName string

The controller name.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, and controller name.

RedirectToActionPermanent(string, string, object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

protected RedirectToRouteResult RedirectToActionPermanent(string actionName, string controllerName, object routeValues)

Parameters

actionName string

The action name.

controllerName string

The controller name.

routeValues object

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

RedirectToActionPermanent(string, string, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

protected virtual RedirectToRouteResult RedirectToActionPermanent(string actionName, string controllerName, RouteValueDictionary routeValues)

Parameters

actionName string

The action name.

controllerName string

The controller name.

routeValues RouteValueDictionary

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

RedirectToActionPermanent(string, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

protected RedirectToRouteResult RedirectToActionPermanent(string actionName, RouteValueDictionary routeValues)

Parameters

actionName string

The action name.

routeValues RouteValueDictionary

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

RedirectToRoute(object)

Redirects to the specified route using the specified route values.

protected RedirectToRouteResult RedirectToRoute(object routeValues)

Parameters

routeValues object

The parameters for a route.

Returns

RedirectToRouteResult

The redirect-to-route result object.

RedirectToRoute(string)

Redirects to the specified route using the route name.

protected RedirectToRouteResult RedirectToRoute(string routeName)

Parameters

routeName string

The name of the route.

Returns

RedirectToRouteResult

The redirect-to-route result object.

RedirectToRoute(string, object)

Redirects to the specified route using the route name and route values.

protected RedirectToRouteResult RedirectToRoute(string routeName, object routeValues)

Parameters

routeName string

The name of the route.

routeValues object

The parameters for a route.

Returns

RedirectToRouteResult

The redirect-to-route result object.

RedirectToRoute(string, RouteValueDictionary)

Redirects to the specified route using the route name and route dictionary.

protected virtual RedirectToRouteResult RedirectToRoute(string routeName, RouteValueDictionary routeValues)

Parameters

routeName string

The name of the route.

routeValues RouteValueDictionary

The parameters for a route.

Returns

RedirectToRouteResult

The redirect-to-route result object.

RedirectToRoute(RouteValueDictionary)

Redirects to the specified route using the route dictionary.

protected RedirectToRouteResult RedirectToRoute(RouteValueDictionary routeValues)

Parameters

routeValues RouteValueDictionary

The parameters for a route.

Returns

RedirectToRouteResult

The redirect-to-route result object.

RedirectToRoutePermanent(object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route values.

protected RedirectToRouteResult RedirectToRoutePermanent(object routeValues)

Parameters

routeValues object

The route name.

Returns

RedirectToRouteResult

Returns an instance of the RedirectResult class with the Permanent property set to true.

RedirectToRoutePermanent(string)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name.

protected RedirectToRouteResult RedirectToRoutePermanent(string routeName)

Parameters

routeName string

The route name.

Returns

RedirectToRouteResult

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name.

RedirectToRoutePermanent(string, object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name and route values.

protected RedirectToRouteResult RedirectToRoutePermanent(string routeName, object routeValues)

Parameters

routeName string

The route name.

routeValues object

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified route name and route values.

RedirectToRoutePermanent(string, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name and route values.

protected virtual RedirectToRouteResult RedirectToRoutePermanent(string routeName, RouteValueDictionary routeValues)

Parameters

routeName string

The route name.

routeValues RouteValueDictionary

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true.

RedirectToRoutePermanent(RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route values.

protected RedirectToRouteResult RedirectToRoutePermanent(RouteValueDictionary routeValues)

Parameters

routeValues RouteValueDictionary

The route values.

Returns

RedirectToRouteResult

An instance of the RedirectResult class with the Permanent property set to true using the specified route values.

TryUpdateModel<TModel>(TModel)

Updates the specified model instance using values from the controller's current value provider.

protected bool TryUpdateModel<TModel>(TModel model) where TModel : class

Parameters

model TModel

The model instance to update.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

Exceptions

ArgumentNullException

The model parameter or the ValueProvider property is null.

TryUpdateModel<TModel>(TModel, string)

Updates the specified model instance using values from the controller's current value provider and a prefix.

protected bool TryUpdateModel<TModel>(TModel model, string prefix) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

Exceptions

ArgumentNullException

The model parameter or the ValueProvider property is null.

TryUpdateModel<TModel>(TModel, string, string[])

Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.

protected bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

Exceptions

ArgumentNullException

The model parameter or the ValueProvider property is null.

TryUpdateModel<TModel>(TModel, string, string[], string[])

Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include.

protected bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

excludeProperties string[]

A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties parameter list.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

Exceptions

ArgumentNullException

The model parameter or the ValueProvider property is null.

TryUpdateModel<TModel>(TModel, string, string[], string[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude , and a list of properties to include.

protected bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

excludeProperties string[]

A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties parameter list.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryUpdateModel<TModel>(TModel, string, string[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and included properties.

protected bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryUpdateModel<TModel>(TModel, string, IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

protected bool TryUpdateModel<TModel>(TModel model, string prefix, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryUpdateModel<TModel>(TModel, string[])

Updates the specified model instance using values from the controller's current value provider and included properties.

protected bool TryUpdateModel<TModel>(TModel model, string[] includeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

includeProperties string[]

A list of properties of the model to update.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryUpdateModel<TModel>(TModel, string[], IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

protected bool TryUpdateModel<TModel>(TModel model, string[] includeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

includeProperties string[]

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryUpdateModel<TModel>(TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

protected bool TryUpdateModel<TModel>(TModel model, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Returns

bool

true if the update is successful; otherwise, false.

Type Parameters

TModel

The type of the model object.

TryValidateModel(object)

Validates the specified model instance.

protected bool TryValidateModel(object model)

Parameters

model object

The model to validate.

Returns

bool

true if the model validation is successful; otherwise, false.

TryValidateModel(object, string)

Validates the specified model instance using an HTML prefix.

protected bool TryValidateModel(object model, string prefix)

Parameters

model object

The model to validate.

prefix string

The prefix to use when looking up values in the model provider.

Returns

bool

true if the model validation is successful; otherwise, false.

UpdateModel<TModel>(TModel)

Updates the specified model instance using values from the controller's current value provider.

protected void UpdateModel<TModel>(TModel model) where TModel : class

Parameters

model TModel

The model instance to update.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string)

Updates the specified model instance using values from the controller's current value provider and a prefix.

protected void UpdateModel<TModel>(TModel model, string prefix) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

A prefix to use when looking up values in the value provider.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string, string[])

Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.

protected void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

A prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string, string[], string[])

Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include.

protected void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

A prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

excludeProperties string[]

A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties list.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string, string[], string[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude, and a list of properties to include.

protected void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

excludeProperties string[]

A list of properties to explicitly exclude from the update. These are excluded even if they are listed in the includeProperties parameter list.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string, string[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

protected void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

The prefix to use when looking up values in the value provider.

includeProperties string[]

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string, IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

protected void UpdateModel<TModel>(TModel model, string prefix, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

prefix string

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string[])

Updates the specified model instance using values from the controller object's current value provider.

protected void UpdateModel<TModel>(TModel model, string[] includeProperties) where TModel : class

Parameters

model TModel

The model instance to update.

includeProperties string[]

A list of properties of the model to update.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, string[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

protected void UpdateModel<TModel>(TModel model, string[] includeProperties, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

includeProperties string[]

A list of properties of the model to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Type Parameters

TModel

The type of the model object.

UpdateModel<TModel>(TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

protected void UpdateModel<TModel>(TModel model, IValueProvider valueProvider) where TModel : class

Parameters

model TModel

The model instance to update.

valueProvider IValueProvider

A dictionary of values that is used to update the model.

Type Parameters

TModel

The type of the model object.

ValidateModel(object)

Validates the specified model instance.

protected void ValidateModel(object model)

Parameters

model object

The model to validate.

ValidateModel(object, string)

Validates the specified model instance using an HTML prefix.

protected void ValidateModel(object model, string prefix)

Parameters

model object

The model to validate.

prefix string

The prefix to use when looking up values in the model provider.

View()

Creates a ViewResult object that renders a view to the response.

protected ViewResult View()

Returns

ViewResult

The View() result that renders a view to the response.

View(object)

Creates a ViewResult object by using the model that renders a view to the response.

protected ViewResult View(object model)

Parameters

model object

The model that is rendered by the view.

Returns

ViewResult

The view result.

View(string)

Creates a ViewResult object by using the view name that renders a view.

protected ViewResult View(string viewName)

Parameters

viewName string

The name of the view that is rendered to the response.

Returns

ViewResult

The view result.

View(string, object)

Creates a ViewResult object that renders the specified IView object.

protected ViewResult View(string viewName, object model)

Parameters

viewName string

The view that is rendered to the response.

model object

The model that is rendered by the view.

Returns

ViewResult

The view result.

View(string, string)

Creates a ViewResult object using the view name and master-page name that renders a view to the response.

protected ViewResult View(string viewName, string masterName)

Parameters

viewName string

The name of the view that is rendered to the response.

masterName string

The name of the master page or template to use when the view is rendered.

Returns

ViewResult

The view result.

View(string, string, object)

Creates a ViewResult object using the view name, master-page name, and model that renders a view.

protected virtual ViewResult View(string viewName, string masterName, object model)

Parameters

viewName string

The name of the view that is rendered to the response.

masterName string

The name of the master page or template to use when the view is rendered.

model object

The model that is rendered by the view.

Returns

ViewResult

The view result.

View(IView)

Creates a ViewResult object that renders the specified IView object.

protected ViewResult View(IView view)

Parameters

view IView

The view that is rendered to the response.

Returns

ViewResult

The view result.

View(IView, object)

Creates a ViewResult object that renders the specified IView object.

protected virtual ViewResult View(IView view, object model)

Parameters

view IView

The view that is rendered to the response.

model object

The model that is rendered by the view.

Returns

ViewResult

The view result.