Commit Graph

1212 Commits

Author SHA1 Message Date
Ryan Nowak e1069dbf65 Fix for #384 - And some other changes to controller as filter
This is a major change to how we handle the scenario where a controller is
a filter. We want to change the lifetime of the controller object, by
scoping it around action filters and result filters. This means that a
controller class can only implement action filters and result filters.

To implement #384 - we're creating a delegating filter class
'ControllerFilter' which will forward calls to the implementation of the
controller. This is discovered in the controller model and added to the
filter collection. This filter is removable as an opt-out of this feature.

The ControllerFilter only implements action filter and result filter, so
the new restriction about filter types on Controller is in place. A future
change will move the instantiation of the controller to after resource
filters.
2015-01-16 19:17:39 -08:00
Ryan Nowak 12c2759cec Fix for #384 - And some other changes to controller as filter
This is a major change to how we handle the scenario where a controller is
a filter. We want to change the lifetime of the controller object, by
scoping it around action filters and result filters. This means that a
controller class can only implement action filters and result filters.

To implement #384 - we're creating a delegating filter class
'ControllerFilter' which will forward calls to the implementation of the
controller. This is discovered in the controller model and added to the
filter collection. This filter is removable as an opt-out of this feature.

The ControllerFilter only implements action filter and result filter, so
the new restriction about filter types on Controller is in place. A future
change will move the instantiation of the controller to after resource
filters.
2015-01-16 19:15:59 -08:00
Ryan Nowak 51e7812e7e Fix for #1722 - FromHeader does not respect default value
This change adds support for our three-valued logic to the default value
handling part of the MutableObjectModelBinder.

The issue is that we want to look up a default value when a 'greedy' model
binder returns true but doesn't find a value.

We also don't want to call the property setter unless there is:
1). A value from model binding OR
2). A default value
2015-01-16 17:59:00 -08:00
Ryan Nowak 692a07240c Some cleanup of ActionResults - #657
In general all properties are get/set so filters can change them.
 - some validate for not-null
 - where we use services it's get/set also

Services are resolved in the Execute method if not provided.

A few more ActionResults that return a body have the ability to set a
status code now (optional).
2015-01-16 17:29:56 -08:00
Kirthi Krishnamraju e41e5066f9 Added support for TryValidateModel and its corresponding tests 2015-01-16 17:23:59 -08:00
Doug Bunting 12565daf88 Correct `CheckBoxFor` to ignore `ViewData`
- #1483
- update tests to match

nits:
- cover a couple more `CheckBoxFor` test cases
- capitalize "CheckBox" consistently
2015-01-16 17:20:34 -08:00
Pranav K 80ada8d01b Introducing 'cache' tag helper
Fixes #1552
2015-01-16 16:57:33 -08:00
N. Taylor Mullen eb1eca9e1a Modify TagHelper tests to abide by new content mode design.
- React to aspnet/Razor#221
- Modified existing TagHelper tests to no longer rely on ContentBehavior.
- Updated signatures of TagHelperExecutionContext and TagHelperContext pieces.
2015-01-16 15:56:03 -08:00
N. Taylor Mullen 7b52559366 Modify TagHelpers to use new content mode design.
- React to aspnet/Razor#221
- Modified existing TagHelpers to no longer rely on ContentBehavior and to instead utilize GetChildContentAsync, PreContent, Content and PostContent.
2015-01-16 15:50:27 -08:00
Youngjune Hong 2cf56c7c83 Merge branch 'fix1771' into dev 2015-01-16 15:30:42 -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
Doug Bunting 9b2a9e3976 Change `ValidationSummaryTagHelper`'s property to `ValidationSummary` enum
- #1685
- move `ValidationSummary` type to the `Microsoft.AspNet.Mvc` namespace
- update tests and samples to match
- remove tests for case-insensitivity of `ValidationSummary` property values
2015-01-16 15:09:27 -08:00
Harsh Gupta 60fa4a6f45 Adding Support for consumes.
Consumes has overriding behavior and the one closest to action wins.
2015-01-16 14:15:08 -08:00
Youngjune Hong dfb02e58f8 Merge branch 'dev' of github.com:aspnet/Mvc into dev 2015-01-16 13:57:32 -08:00
Youngjune Hong 0d2a819255 Remove Controller.ViewEngine property+unit tests and simplify the Content method 2015-01-16 13:44:03 -08:00
Pranav K a94d5223e1 Modify RoslynCompilationService to read MetadataReferences from the target 2015-01-16 12:39:04 -08:00
Ajay Bhargav Baaskaran b02dea98e7 Using set instead of add in Created ActionResults 2015-01-16 12:34:40 -08:00
Ajay Bhargav Baaskaran 7c0eb56e59 ContentResult sets Charset along with ContentType
- Sets default ContentType and Charset if null
- Added relevant unit and functional tests
2015-01-16 12:24:44 -08:00
Ajay Bhargav Baaskaran a5a3eb44b9 Activation behavior modification made easier
- Made Activate method virtual
 - Changed IReadOnlyDictionary to IDictionary
2015-01-16 12:15:28 -08:00
Yishai Galatzer 9ac37fbc7a Rename TextPlainFormatter and remove other minor warnings
#1631
2015-01-16 12:09:53 -08:00
David Fowler 90f2ece84d Work around dependency resolution problem 2015-01-16 03:01:51 -08:00
Hao Kung 7b2fb55ef6 React to Security Auth changes 2015-01-15 23:41:52 -08:00
sornaks 262bb9a732 Changes introducing ResponseCache to cache content in the client/proxy. 2015-01-15 16:51:22 -08:00
Doug Bunting d2fe1ebad7 Allow `@Model` in bound tag helper attribute value
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nits:
- remove a few unecessary `@`s in .cshtml files
- correct field names & ids in ProductList.cshtml (`foreach` confuses MVC)
 - led to correct valiation attributes as well
2015-01-15 16:47:27 -08:00
Doug Bunting a77d071830 React to aspnet/Razor#268 changes
- part I of #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
2015-01-15 16:47:22 -08:00
Ryan Nowak 3dea6b11a3 Issue #1695 - Create a pattern for a 'greedy' model binder.
See #1695 for a detailed explanation. This change builds support into the
system for the case that a model binder returns true without setting a
value for the Model.

In this case, validation will be skipped if it's a top-level object.

Note that explicitly setting null will still run validation.
2015-01-15 16:32:50 -08:00
Ryan Nowak 623b733eaa Adding a sample (test) for using custom IRouter implementation with MVC
This is a demonstration of how to inject an IRouter in between traditional
routes and MVC's handler. This allows you to accomplish a variety of
things that were possible with WebAPIs handlers, but inside the routing
system.

The example here turns a header representing the user into a locale, which
is used to select a controller. You could do other things like reject the
route match or change link generation.

There is one subtle project change here, to allow the same to be possible
for attribute routing, we need to create the attribute route after running
the user's routing configuration code.
2015-01-15 16:31:21 -08:00
Kiran Challa 02f4ca9f05 [Fixes #1791]Remove XML formatter from defaults 2015-01-15 15:46:49 -08:00
Chris Ross 9aff289dfe Handle PipelineCore rename. 2015-01-15 15:25:17 -08:00
Pranav K bef9af4679 Fixing build break
* Run ModelBinding test that uses Moq to run under ASPNET50
* Update AssociatedValidatorProviderTest to reflect API changes
2015-01-15 14:20:00 -08:00
Pranav K fe1bcc7a24 ElementalValueProvider performs incorrect prefix check in
ContainsPrefixAsync

Fixes #1814
2015-01-15 14:02:41 -08:00
Pranav K b24cec0add Add net45 as a target framework for Microsoft.AspNet.Mvc.Common 2015-01-15 14:02:36 -08:00
Ajay Bhargav Baaskaran 437eb93bde File upload model binder
- Support for binding posted file to type IFormFile
- Support for multipart/form-data in FormValueProviderFactory
- Updated Mvc Sample
- Added relevant unit and functional tests
2015-01-15 13:41:14 -08:00
Kirthi Krishnamraju 6a824a4394 Added ModelMetadataType Attribute and logic to get attributes from ModelMetadata class 2015-01-15 13:19:10 -08:00
Pranav K 6641997836 Add support for `@removeTagHelpers` inheritance from _ViewStart files
Fixes #1657
2015-01-15 12:12:00 -08:00
Harsh Gupta 106b9fc30c Adding proper descriptions in readme.md files for functional tests. 2015-01-15 11:12:48 -08:00
Chris Ross 91d7e382d1 Consume new strongly typed headers. Remove temp implementations. 2015-01-14 15:51:34 -08:00
N. Taylor Mullen 8529ea2f0d React to aspnet/Razor#240.
- Updated tests to account for new casing.
2015-01-13 22:35:43 -08:00
NTaylorMullen 4c20352e2a Updated test files to react to aspnet/Razor#260. 2015-01-13 21:32:05 -08:00
Doug Bunting 89fd1abc58 Nit: Clean up duplicate tests
- lead to errors during test discovery in VS
2015-01-13 12:49:26 -08:00
Doug Bunting 6e68637af1 Nit: Remove unneeded sample dependencies on Microsoft.AspNet.Mvc.TestConfiguration 2015-01-13 12:49:22 -08:00
Doug Bunting c0d27ee56d Add `CultureReplacerMiddleware` for use in functional test web sites
- #1766
- use `ReplaceCultureAttribute` to avoid `CultureReplacer` thread consistency checks
- also update test expectations to match new formats

nit: use `UseMiddleware()` extension method rather than `app.Use()`
2015-01-13 12:49:02 -08:00
Youngjune Hong 40e479c915 MvcTagHelpers tests for
1) A few `<input/>` tag helpers in a partial view invoked (`@Html.PartialAsync()`) in a loop within a `@for` inside an `using @Html.BeginForm()` block.
2) A custom template e.g. EditorTemplates/MyType.cshtml containing a mix of `<input/>`, `<select/>`, and various input HTML helpers invoked (`@Html.Editor[For]()`) in a loop within a `@for` inside an `using @Html.BeginForm()` block.
3)  `<select/>` tag helpers with an `using @Html.BeginForm()` block
4) HTML helpers in the <form/> tag helper
2015-01-13 10:12:19 -08:00
Pranav K cbea96cf37 Reacting to Roslyn version change 2015-01-13 08:19:49 -08:00
Pranav K b7d44666b8 Adding support for flowing compilation errors to Diagnostics middleware
Fixes #872
2015-01-13 07:32:58 -08:00
Ajay Bhargav Baaskaran 62b6ab8721 Added missed license header and removed unused file 2015-01-12 17:42:05 -08:00
Ryan Nowak 08b83fefc3 Some cleanup of action invoker and related code
The action invoker no longer needs access to model metadata or to the
input formatter selector. This change removes the same as constructor
parameters and cleans up tests which use the invoker.
2015-01-12 16:44:39 -08:00
Ryan Nowak 61d9c2cbf8 fix build break 2015-01-12 14:36:21 -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
stanislavromanov 990473aebc Change remark for FlushAsync method. close #1721 2015-01-12 14:07:58 -08:00