using System;


Templated Helper Methods

Generate an element that can be used to edit a model property
Use the Html.Editor and Html.EditorFor helpers

Generate labels for and read-only representations of model properties
Use the Html.Label and Html.Display helpers

Generate elements for a complete model object
Use the DisplayForModel, EditorForModel and LabelForModel helpers

Hide an element from the user when generating elements using a whole-model helper or prevent it from being edited
Apply the HiddenInput attribute to the property

Set the label that will be used to display model properties
Use the DisplayName and Display properties

Specify the way in which model properties are displayed
Use the DataType attribute

Specify the template used to display a model property
Use the UIHint attribute

Define model metadata separately from the model type
Create a buddy class and use the MetadataType attribute

Change the elements that are generated for a model property
Create a custom template


Helper Methods

Create a region of reusable markup within a view
Create an inline helper

Create markup that can be used within multiple views
Create an external helper

Generate a form element
Use the Html.BeginForm and Html.EndForm helpers

Generate a form element using a specific route
Use the Html.BeginRouteForm helper

Generate input elements
Use the input helpers

Generate input elements from model objects
Use the strongly typed input helpers

Generate select elements
Use the DropDownList and ListBox helpers and their strongly typed counterparts



Create a custom view engine
Implement the IViewEngine and IView interfaces

Customize the Razor view engine
Derive from the RazorViewEngine class

Define regions of content for use in a layout
Use Razor sections

Apply sections in a layout
Use the RenderSection and RenderBody helpers

Define reusable fragments of markup
Use partial views

Define reusable business logic
Use child actions


Controller Extensibility

Create a custom controller factory
Implement the IControllerFactory interface

Prioritize namespaces in the default controller factory
Use the DefaultNamespaces collection

Create a custom controller activator
Implement the IControllerActivator interface

Create a custom action invoker
Implement the IActionInvoker interface

Specify an action name that is different from the action method name
Use the ActionName attribute

Control the selection of action methods
Apply action method selectors

Prevent a method from being used as an action
Use the NoAction attribute

Create a custom action method selector
Derive from the ActionMethodSelectorAttribute class

Respond to requests for non-existent action methods
Override the HandleUnknownAction method in the controller

Control how controllers use the session feature
Return a value from the SessionStateBehavior enumeration in the IControllerFactory implementation or apply the SessionState attribute to the controller class

Prevent controller from blocking worker threads when waiting for input
Create an asynchronous controller



Inject extra logic into request processing
Apply filters to the controller or its action methods

Restrict action methods to specific users and groups
Use authorization filters

Authenticate requests
Use authentication filters

Process errors when executing requests
Use exception filters

Inject general-purpose logic into the request handling process
Use action filters

Inspect or alter the results generated by action methods
Use result filters

Use filters without attributes
Use the built-in controller methods

Define filters that apply to all action methods in the application
Define global filters

Control the order in which filters are executed
Use the Order parameter

Override global and controller filters for an action method
Use an override filter


Controllers And Actions

Create a controller
Implement the IController interface or derive from the Controller class

Get information about a request
Use the context objects and properties or define action method parameters

Generate a response from controller that directly implements the IController interface
Use the HttpResponse context object

Generate a response from a controller derived from the Controller class
Use an action result

Tell the MVC Framework to render a view
Use a ViewResult

Pass data from the controller to the view
Use a view model object or the view bag

Redirect the browser to a new URL
Use the Redirect or RedirectToPermanent methods

Redirect the browser to a URL generated by a route
Use the RedirectToRoute or RedirectToRoutePermanent methods

Redirect the browser to another action method
Use the RedirectToAction method

Send an HTTP result code to the browser
Return an HttpStatusCodeResult object or use one of the convenience methods such as HttpNotFound


More Routing Features

Generate an a element with an outgoing URL
Use the Html.ActionLink helper method

Provide values for segment variables
Pass an anonymous object to the ActionLink helper whose properties correspond to the segment variable names

Define attributes for the a element
Pass an anonymous object to the ActionLink helper whose properties correspond to the attribute names

Generate an outgoing URL without the a element
Use the Url.Action helper method

Generate a URL from a specific route
Specify the route name when calling the helper

Create a custom URL matching and generation policy
Derive from the RouteBase class

Create a custom mapping between URLs and action methods
Implement the IRouteHandler interface

Break an application into sections
Create areas or apply the RouteArea attribute

Resolve controller name ambiguity in areas
Give priority to a controller namespace

Prevent IIS and ASP.NET processing requests for static files before they are passed to the routing system
Use the RouteExistingFiles property

Prevent the routing system from processing a request
Use the IgnoreRoute method



Map between URLs and action methods
Define a route

Allow URL segments to be omitted
Define default values for segment variables

Match URL segments that don't have corresponding routing variables
Use static segments

Pass URL segments to action methods
Define custom segment variables

Allow URL segments for which there is no default value to be omitted
Define optional segments

Define routes that match any number of URL segments
Use a catchall segment

Avoid controller name confusion
Specify priority namespaces in a route

Limit the URLs that a route can match
Apply a route constraint

Enable attribute routing
Call the MapMvcAttributeRoutes method

Define a route within a controller
Apply the Route attribute to the action methods

Constrain an attribute route
Apply a constraint to the segment variable in the route pattern

Define a common prefix for all of the attribute routes in a controller
Apply the RoutePrefix attribute to the controller class


Dependencies, Decoupling, Unit Testing

Decouple classes
Introduce interfaces and declare dependencies on them in the class constructor

Automatically resolve dependencies expressed using interfaces
Use Ninject or another dependency injection container

Integrate Ninject into an MVC application
Create an implementation of the IDependencyResolver interface that calls the Ninject kernel and register it as a resolver by calling the System.Web.Mvc.DependencyResolver.SetResolver method

Inject property and constructor values into newly created objects
Use the WithPropertyValue and WithConstructorArgument methods

Dynamically select an implementation class for an interface
Use an Ninject conditional binding

Control the lifestyle of the objects that Ninject creates
Set an object scope

Create a unit test
Add a unit test project to the solution and annotate a class file with TestClass and TestMethod attributes

Check for expected outcomes in a unit test
Use the Assert class

Focus a unit test on a single feature of component
Isolate the test target using mock objects



Define and access the model type.
Use the @model and @Model expressions.

Reduce duplication in views
Use a layout

Specify a default layout
Use the view start view

Pass data values to the view from the controller
Pass a view model object or the view bag

Generate different content based on data values
Use razor conditional statements

Enumerate an array or a collection
Use a @foreach expression

Add a namespace to a view
Use a @using expression

Stariji postovi

<< 08/2017 >>




Powered by