Class Controller
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
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
RequestContextThe request context.
callback
AsyncCallbackThe asynchronous callback.
state
objectThe 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
AsyncCallbackThe callback.
state
objectThe 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
stringThe 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
stringThe content to write to the response.
contentType
stringThe 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
stringThe content to write to the response.
contentType
stringThe content type (MIME type).
contentEncoding
EncodingThe 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
booltrue 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
IAsyncResultThe asynchronous result.
EndExecuteCore(IAsyncResult)
Ends the execute core.
protected virtual void EndExecuteCore(IAsyncResult asyncResult)
Parameters
asyncResult
IAsyncResultThe 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
stringThe 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
stringThe content type (MIME type).
fileDownloadName
stringThe 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
StreamThe stream to send to the response.
contentType
stringThe 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
StreamThe stream to send to the response.
contentType
stringThe content type (MIME type)
fileDownloadName
stringThe 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
stringThe path of the file to send to the response.
contentType
stringThe 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
stringThe path of the file to send to the response.
contentType
stringThe content type (MIME type).
fileDownloadName
stringThe 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
stringThe 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
stringThe 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
RequestContextThe HTTP context and route data.
JavaScript(string)
Creates a JavaScriptResult object.
protected virtual JavaScriptResult JavaScript(string script)
Parameters
script
stringThe 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
objectThe 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
objectThe JavaScript object graph to serialize.
contentType
stringThe 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
objectThe JavaScript object graph to serialize.
contentType
stringThe content type (MIME type).
contentEncoding
EncodingThe 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
objectThe JavaScript object graph to serialize.
contentType
stringThe content type (MIME type).
contentEncoding
EncodingThe content encoding.
behavior
JsonRequestBehaviorThe 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
objectThe JavaScript object graph to serialize.
contentType
stringThe content type (MIME type).
behavior
JsonRequestBehaviorThe 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
objectThe JavaScript object graph to serialize.
behavior
JsonRequestBehaviorThe 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
ActionExecutedContextInformation about the current request and action.
OnActionExecuting(ActionExecutingContext)
Called before the action method is invoked.
protected virtual void OnActionExecuting(ActionExecutingContext filterContext)
Parameters
filterContext
ActionExecutingContextInformation about the current request and action.
OnAuthentication(AuthenticationContext)
Called when authorization occurs.
protected virtual void OnAuthentication(AuthenticationContext filterContext)
Parameters
filterContext
AuthenticationContextInformation about the current request and action.
OnAuthenticationChallenge(AuthenticationChallengeContext)
Called when authorization challenge occurs.
protected virtual void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
Parameters
filterContext
AuthenticationChallengeContextInformation about the current request and action.
OnAuthorization(AuthorizationContext)
Called when authorization occurs.
protected virtual void OnAuthorization(AuthorizationContext filterContext)
Parameters
filterContext
AuthorizationContextInformation 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
ExceptionContextInformation 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
ResultExecutedContextInformation 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
ResultExecutingContextInformation 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
objectThe 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
stringThe 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
stringThe name of the view that is rendered to the response.
model
objectThe 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
stringThe 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
stringThe 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
stringThe 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
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
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
stringThe name of the action.
controllerName
stringThe name of the controller.
routeValues
objectThe 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
stringThe name of the action.
controllerName
stringThe name of the controller.
routeValues
RouteValueDictionaryThe 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
stringThe name of the action.
routeValues
RouteValueDictionaryThe 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
stringThe 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
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
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
stringThe action name.
controllerName
stringThe controller name.
routeValues
objectThe 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
stringThe action name.
controllerName
stringThe controller name.
routeValues
RouteValueDictionaryThe 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
stringThe action name.
routeValues
RouteValueDictionaryThe 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
objectThe 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
stringThe 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
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
stringThe name of the route.
routeValues
RouteValueDictionaryThe 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
RouteValueDictionaryThe 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
objectThe 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
stringThe 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
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
stringThe route name.
routeValues
RouteValueDictionaryThe 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
RouteValueDictionaryThe 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
TModelThe 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
TModelThe model instance to update.
prefix
stringThe 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
TModelThe model instance to update.
prefix
stringThe 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
TModelThe model instance to update.
prefix
stringThe 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
TModelThe model instance to update.
prefix
stringThe 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
IValueProviderA 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
TModelThe model instance to update.
prefix
stringThe prefix to use when looking up values in the value provider.
includeProperties
string[]A list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe model instance to update.
prefix
stringA list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe 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
TModelThe model instance to update.
includeProperties
string[]A list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe model instance to update.
valueProvider
IValueProviderA 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
objectThe 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
objectThe model to validate.
prefix
stringThe 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
TModelThe 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
TModelThe model instance to update.
prefix
stringA 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
TModelThe model instance to update.
prefix
stringA 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
TModelThe model instance to update.
prefix
stringA 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
TModelThe model instance to update.
prefix
stringThe 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
IValueProviderA 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
TModelThe model instance to update.
prefix
stringThe prefix to use when looking up values in the value provider.
includeProperties
string[]A list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe model instance to update.
prefix
stringA list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe 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
TModelThe model instance to update.
includeProperties
string[]A list of properties of the model to update.
valueProvider
IValueProviderA 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
TModelThe model instance to update.
valueProvider
IValueProviderA 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
objectThe model to validate.
ValidateModel(object, string)
Validates the specified model instance using an HTML prefix.
protected void ValidateModel(object model, string prefix)
Parameters
model
objectThe model to validate.
prefix
stringThe 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
objectThe 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
stringThe 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
stringThe view that is rendered to the response.
model
objectThe 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
stringThe name of the view that is rendered to the response.
masterName
stringThe 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
stringThe name of the view that is rendered to the response.
masterName
stringThe name of the master page or template to use when the view is rendered.
model
objectThe 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
IViewThe 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
IViewThe view that is rendered to the response.
model
objectThe model that is rendered by the view.
Returns
- ViewResult
The view result.