Commit Graph

44 Commits

Author SHA1 Message Date
Pranav K f9d53e341c * Simplify MvcOptions
* Remove facades for accessing Options<T> and pass options to the invoker

Fixes #2266
Fixes #2269
2015-04-07 14:45:53 -07:00
Ryan Nowak f5e7a69693 Updates to the extensibility for validator providers
This change removes reflection from validator providers, and instead
relies on cached metadata in in the modelmetadata.

In general this means that our MVPs don't need to cache anything, they
just look at the metadata and create what they need.

In the case of data-annotations, we update the model details provider to
add validation attributes to the modelmetadata. This would allow someone
to replace the DataAnnotationsValidatorProvider, but still use the
metadata in these attributes.

The change to the IModelValidatorProvider api (to use a context) is
intended to minimize allocations. Currently each validator provider needs
to return a list so you end up with N+1 lists (N validators + a final list
to compine them all). This change will let us just create the final list
(and a small context object). This is a very very high traffic API so it
seemed worth doing.

There's also some general massaging of namespaces and file locations.
2015-03-20 15:19:25 -07:00
Ajay Bhargav Baaskaran fc9e1caf43 [Fixes #1331] Register object for dispose in ObjectResult and
FileStreamResult
2015-03-17 17:04:05 -07:00
Ajay Bhargav Baaskaran db728cd386 Introducing TempData
- Issue #455
 - Updated MVC sample
 - Added relevant tests
2015-03-10 12:04:05 -07:00
N. Taylor Mullen e829ba7646 Update aspnet50/aspnetcore50 => dnx451/dnxcore50. 2015-03-08 12:52:24 -07:00
ianhong 1144ba72d5 Porting HttpUnauthorizedResult 2015-03-06 10:18:51 -08:00
Ryan Nowak 90cef3b9ca Refactor of the model metadata provider
Separates the MMP into two phases:
1). Creation of the ModelMetadata, discovery of properties and attributes
(reflection) is part of the MMP
2). Lookup of details based on attributes is now part of another phase,
and has its results cached.

Users can now implements and register an IFooMetadataProvider to customize
a single aspect of metadata (see how data annotations does it).
2015-03-05 13:19:10 -08:00
Ajay Bhargav Baaskaran dc49a2c194 Added HttpNotFoundObjectResult and added relevant tests 2015-02-24 11:57:48 -08:00
Kirthi Krishnamraju f6e701b2b2 Reverting #1837 and add non-generic overloads for TryUpdateModel 2015-02-23 10:02:51 -08:00
Harsh Gupta f19c2e493d Merging Model Validation for body and non body validation.
This also fixes #1503.

Currently all model binders except mutable object binder are independent of validation code. The mutable object binder which needs to do some validation ( for scenarios involving [BindRequired] and [BindNever]).
We would be going with an approach where required validaiton happens in input formatters and model binders.
This is needed as validation for value types can best be done at creation time.

Followup PRs:
Introduce support for skipping validation (and not binding) for a particular property/type etc.
2015-02-17 11:50:39 -08:00
Pranav K 5e69d90076 * Modify DefaultControllerTypeProvider to look at the object graph to
determine if any ancestor has the "Controller" suffix.

* Introduce NonControllerAttribute to opt out of Controller detection.

Fixes #1274
2015-02-15 22:11:37 -08:00
Youngjune Hong 57c04835de Updating ActionContext for the default constructor and the setter methods 2015-02-06 20:27:42 -08:00
Ajay Bhargav Baaskaran ac6a1a6a80 Replaced status code number with constants 2015-02-05 16:43:59 -08:00
Kirthi Krishnamraju e41e5066f9 Added support for TryValidateModel and its corresponding tests 2015-01-16 17:23:59 -08:00
Youngjune Hong ba1c011bcb [ControllerUnitTest] Make the controller class not to throw an exception for simple unit tests 2015-01-16 15:22:04 -08:00
Youngjune Hong 0d2a819255 Remove Controller.ViewEngine property+unit tests and simplify the Content method 2015-01-16 13:44:03 -08:00
Ryan Nowak 5ac5c53c09 Adding Resource Filters
This is a new filter stage that surrounds the existing model binding,
action, and result parts of the pipeline. Resource Filters run after
Authorization Filters.

The other major change is to support one of the primary scenarios for
Resource Filters. We want a filter to be able to modify the inputs the
model binding (formatters, model binders, value providers, etc) -- this
means that those changes need to be held on a context object and preserved
so that they can be used in the controller.

So, IActionBindingContextProvider is removed - the ActionBindingContext
will be created by the invoker. For now it will be part of the action
context.
2015-01-12 14:18:20 -08:00
Doug Bunting 6df288bce7 Correct StyleCop violations
- StyleCop working again (handles C# 6.0 additions) though only locally for me
- disable some new rules:
 - ConstFieldNamesMustBeginWithUpperCaseLetter
 - InstanceReadonlyElementsMustAppearBeforeInstanceNonReadonlyElements
 - StaticReadonlyElementsMustAppearBeforeStaticNonReadonlyElements
 - StaticReadonlyFieldsMustBeginWithUpperCaseLetter
 - PrefixCallsCorrectly
- correct remaining violations
 - lots of long lines for example
 - use more `var`; some manual updates since StyleCop doesn't check seemingly-unused blocks

nit: remove new trailing whitespace (was paranoid about adding it w/ fixes)
2015-01-06 16:23:57 -08:00
sornaks 5262dfd577 Adding SerializableError - a serializable container for the purpose of output conneg. 2015-01-06 14:07:45 -08:00
Ajay Bhargav Baaskaran eb7283fced added BadRequest and Created Action Results with related unit and functional tests. 2015-01-05 11:07:42 -08:00
Harsh Gupta 2353bd911a Adding Support for TryUpdateModel using include expressions and predicate. 2014-11-26 17:44:50 -08:00
Doug Bunting 315908af5f Apply VS' FormatDocument and RemoveAndSort to all *.cs files
- #EngineeringDay
- VS does not yet format auto-properties nicely; reverted what it did

Also revert changes under
- test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles
2014-11-20 21:15:46 -08:00
Doug Bunting 5e067cdb9e Delete trailing whitespace
- #EngineeringDay
- Total replaced: 660  Matching files: 270 in *.cs
- Total replaced: 250  Matching files: 32 in all other files
- Total replaced: 22  Matching files: 8 in a few stragglers

Did not change files under following directories
- test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
- test\Microsoft.AspNet.Mvc.FunctionalTests\compiler\resources
- test\WebSites\TagHelpersWebSite
(Razor generates trailing whitespace in a case or two)
2014-11-20 16:18:09 -08:00
kanchanm 4598505652 Fix to special case Dispose method to be treated as non-action 2014-11-12 14:52:19 -08:00
Pranav K bd82e584f0 Porting over unit tests for ViewDataDictionary.Eval
Partial fix for #453
2014-10-17 17:27:05 -07:00
YishaiGalatzer 80ef37ab0a Add unit tests to controller properties 2014-10-09 18:18:03 -07:00
jacalvar a2023d35ee [Fixes #429] FileResult
1) Implemented FilePathResult to efficiently return files from disk.
2) Implemented FileStreamResult to return content from a stream.
3) Implemented FileContentResult to return content from a byte array.
2014-10-02 12:50:24 -07:00
Pranav K 38e82c0aa5 Updating Microsoft.AspNet.Mvc.Core.Test to work on Mono 2014-10-01 10:05:36 -07:00
David Fowler 34add2249e Updated to use the new target framework in project.json 2014-09-04 02:02:40 -07:00
jacalvar b6fb7ac7df Take advantage of nameof to improve our usage of MemberData across the code base.
Substituted all instances of [MemberData("PropertyName")] for [MemberData(nameof(PropertyName))]
This change enables us to take advantage of IDE features like Navigate to source,
find all references, etc. When using Visual Studio.
2014-09-02 13:53:03 -07:00
Pranav K d604c18368 Moving IModelValidatorProvider to Options
Fixes #879
2014-08-26 11:53:32 -07:00
harshgMSFT 6f0fa67170 Enabling basic input formatter selection.
Conflicts:
	Mvc.sln
	src/Microsoft.AspNet.Mvc.Core/Formatters/TempInputFormatterProvider.cs
	src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
	src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs
	src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvokerProvider.cs
	src/Microsoft.AspNet.Mvc/MvcServices.cs
	test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj
	test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs

Conflicts:
	src/Microsoft.AspNet.Mvc.Core/Formatters/TempInputFormatterProvider.cs
2014-08-19 12:46:52 -07:00
harshgMSFT bb452f19a7 JsonResult to use ObjectResult for content negotiation to pick default json formatter. 2014-08-15 15:56:24 -07:00
Javier Calvarro Nelson b0d52f73fd [Issue #527] Revive common ActionResults - Part 1.
1. Added HttpNotFound() to Controller.
2. Updated HttpStatusCodeResult to expose the StatusCode as a property.
3. Added unit tests for HttpNotFound() and for HttpStatusCodeResult.
4. Updated the MvcSample to add an action that uses HttpNotFound().
5. Brought back HttpNotFoundResult and added unit tests for it.
2014-07-25 13:04:59 -07:00
Pranav K 24f74222f5 Introducing Controller.TryUpdateModel
This changeset reintroduces some of the overloads for
Controller.TryUpdateModel.

Fixes #415
2014-07-25 10:08:44 -07:00
Tian Pan 4c9f19aafc Update controller methods to be all virtual
Fix #596
2014-06-20 15:40:02 -07:00
Ryan Nowak 1bae3bcaa2 Issue #592 - ActionResult is not being executed by ResultFilterAttribute
The issue here is actually different than described in the bug.
ResultFilter should only short circuit when .Cancel is set to true. This
is consistent with legacy MVC.

Added tests for all of this stuff. There's already good test coverage for
the invoker, what was missing was coverage for the attributes and for the
methods on Controller. ExceptionFilterAttribute and
AuthorizationFilterAttribute don't have short circuiting logic inside of
them, so they are already covered by tests for the invoker.
2014-06-16 12:42:59 -07:00
Tian Pan e95585dfbd Remove ActionResultHelper
Fix #597
2014-06-11 11:17:45 -07:00
Tian Pan 60443101d5 Enable request to reach base controller class's action
Fix #378
2014-06-11 10:57:19 -07:00
Andrew Peters f13865dedc Updating copyright headers 2014-05-08 23:01:20 -07:00
anpete 8208cd6b2f Update file headers 2014-05-01 17:42:33 -07:00
Sornakumar ecd8ddeae4 WebFX 156: Adding support for RedirectToAction and RedirectToRoute 2014-04-15 10:45:57 -07:00
sornaks 7c8dd45b8b WebFX 156 - Adding support for Redirect and RedirectPermanent 2014-04-08 10:49:56 -07:00
dougbu 8ed5b7b079 Fix WebFx-169 and #118
- move `DynamicObject` derivation up to new `DynamicViewData` class, fixing [WebFx-169](http://projectk-tc:8080/browse/WEBFX-169)
- avoid direct `_data` lookup in previous `TryGetMember()`, fixing [#118](https://github.com/aspnet/WebFx/issues/118)
- rename ViewData -> ViewDataDictionary

Also
- flesh out `IDictionary<string, object>` implementation in `ViewData`
- provide `ViewData` copy constructor that allows TModel to change
- remove `TryGetIndex()` and `TrySetIndex()` implementations; use `ViewData[]` instead
- restore `ViewContext.ViewBag` from legacy MVC
2014-03-26 11:42:52 -07:00