Commit Graph

1589 Commits

Author SHA1 Message Date
N. Taylor Mullen 3be7fbdf9f Rename AspNet 5 file contents.
See https://github.com/aspnet/Announcements/issues/144 for more information.
2016-01-22 12:18:33 -08:00
N. Taylor Mullen 6a6c8ca544 Rename AspNet 5 folders and files.
See https://github.com/aspnet/Announcements/issues/144 for more information.
2016-01-22 12:17:07 -08:00
Pranav K 00462abe62 Cleaning up VirtualFileResult tests 2016-01-21 17:56:29 -08:00
Brennan 8765a06b69 React to Fileprovider namespace changes 2016-01-21 17:45:06 -08:00
Ajay Bhargav Baaskaran a47a7fdccc Added caching for ActionConstraints 2016-01-21 17:30:08 -08:00
Ajay Bhargav Baaskaran f0777b95a8 [Fixes #3868] Exclude Antiforgery token in form with method Get 2016-01-21 11:29:41 -08:00
Ryan Nowak dd952d8d70 Move some types to .Internal namespace 2016-01-21 10:56:38 -08:00
Doug Bunting 04453a2b4f Support user overrides of three more framework-provided `ModelState`-related messages
- #3215
- add new accessor properties to `IModelBindingMessageProvider` and plumb them through
  - use in `ModelStateDictionary` when handling a `FormatException` or `OverflowException`
  - use in `ValidationHelpers` when handling a `ModelError` with `null` `ErrorMessage`
- add new `ModelExplorer` parameter to `IHtmlGenerator.GenerateValidationMessage()`
  - plumb through to `ValidationHelpers.GetModelErrorMessageOrDefault()`

Started from work @kichalla did on the `kiran/movemessages-to-messageprovider` branch in #3775.

nits:
- use helper methods more consistently in `HtmlHelper<T>`; slightly improves error checking
- remove unused `Resources` class from `Microsoft.AspNet.Mvc`
- make `ValidationHelpers` class `public`; already in `.Internal` namespace
  - split `GetUserErrorMessageOrDefault()` in two; rename to `GetModelErrorMessageOrDefault()`
- fix some #YOLO wrapping
2016-01-20 21:14:33 -08:00
Derek Gray 328f4d648b Allow ValidationAttributes and IValidatableObjects to resolve services from the RequestServices provider by injecting it into the ValidationContext. 2016-01-20 09:19:24 -08:00
ryanbrandenburg a229b20c48 * StringOutput set proper ContentType 2016-01-19 10:06:30 -08:00
Doug Bunting 2810858905 Add `HtmlEncoder` parameter to `RazorPage.StartTagHelperWritingScope()`
- aspnet/Razor#643 part 2: react to aspnet/Razor#653
 - change test calls and delegates to include new parameter
 - add tests specifically of the new feature
 - add tag helpers using new feature to `TagHelpersTest` functional test
- note `HtmlEncoder`s used elsewhere e.g. in other `RazorPage` instances are unaffected
 - i.e. changing one `RazorPage.HtmlEncoder` property only affects C# expressions in that page

Also simplify scope management, removing bizarre assertion when user does something odd.

nits:
- correct `// Act` and `//  Act & Assert` content
- remove #YOLO wrapping
2016-01-17 22:59:59 -08:00
John Luo 249673f2bc Reacting to hosting rename 2016-01-17 18:13:26 -08:00
Pranav K cf9221df07 Pool JsonSerializer instances
Fixes #3550
2016-01-15 16:13:31 -08:00
Doug Bunting fa8c2eac3e Check encoded and unencoded values against element body in `OptionTagHelper`
- #3386
- initialize comparison `HashSet` with unencoded values to ensure both are checked
- address perf and correctness issues in this code
  - `context.Items[typeof(SelectTagHelper)]` entry read as `ICollection` but written as `IReadOnlyCollection`
    - `IReadOnlyCollection` worse because it does not include `Contains()`, causing Linq use
  - every `<option>` element recalculated the encoded values and created a `HashSet` to contain them
    - add `CurrentValues` type to cache this `HashSet` in `context.Items`
  - each `OptionTagHelper` created the additional `HashSet` even if `Value` was bound
2016-01-14 17:46:54 -08:00
jacalvar 82381d97c2 [Fixes #3907] Improve MVC error when MVC services aren't registered 2016-01-14 15:09:07 -08:00
Pranav K 200fb23ba5 Reduce allocations in GlobbingUrlBuilder 2016-01-14 12:15:41 -08:00
Pranav K e078259547 Modify UrlHelper to use a single StringBuilder 2016-01-14 10:39:35 -08:00
Pranav K aa5a4d4af2 Revert "Revert DependencyContext changes untill dotnet-cli packages get sorted out"
This reverts commit 57bf12311b.
2016-01-13 16:24:33 -08:00
Ryan Nowak 420f442487 Fixes #3818 - Support Consumes in ApiExplorer
This change adds a list of ApiRequestFormat objects to ApiDescription
object which include the content type and formatter for each supported
content type which can be understood by the action.

Computation is aware of the [Consumes] attribute via the
IApiRequestMetadataProvider metadata interface, and aware of Input
Formatters via the new IApiRequestFormatMetadataProvider interface.

This algorithm is essentially the same as what we do for
produces/output-formatters. We iterate the filters and ask them what
content types they think are supported. Then we cross check that list with
the formatters, and ask them which from that list are supported. If no
[Consumes] filters are used, the formatters will include everything they
support by default.

This feature and data is only available when an action has a [FromBody]
parameter, which will naturally exclude actions that handle GET or DELETE
and don't process the body.
2016-01-13 12:32:17 -08:00
John Luo 32bb324886 Removing redundant null logger after hosting fix 2016-01-13 12:14:38 -08:00
Ryan Nowak 70cee90186 Add optional filter caching 2016-01-13 09:11:08 -08:00
javiercn 2063356f24 [Fixes #3683] Replace implementations in MediaTypeComparisons and
MediaTypeEncodings with memory efficient implementations using a MediaType
struct.
2016-01-12 15:09:48 -08:00
javiercn 739f83a978 Support caching of the Content-Type string used by OutputFormatter
when the encoding is Utf-8.
2016-01-12 15:09:46 -08:00
jacalvar 830fd410f5 Remove runtime dependency usage of MediaTypeHeaderValue.
Removes usage of MediaTypeHeaderValue in ApiExplorer, InputFormatters and
OutputFormatters

Public interface changes with stub implementation.
2016-01-12 15:09:46 -08:00
Pranav K 32d15186a0 Remove Razor precompilation 2016-01-12 14:51:33 -08:00
ryanbrandenburg cad7d44686 * Add a sample for SubAreas 2016-01-12 11:48:09 -08:00
N. Taylor Mullen 947d070678 Skip TagHelperSample index test due to mono encoding bug.
Due to aspnet/External#50.
2016-01-12 10:13:47 -08:00
N. Taylor Mullen dbb69ef952 Add `TagHelperSample.Web` functional tests.
- Validated that each of `TagHelperSample.Web`s sites work properly.
- Found that the `ConditionalCommentTagHelper` page wasn't working as intended due to never being updated after `TagHelperContent` encoding changes.
- Added content verification for the `TagHelper/ConditionalComment` endpoint only since it's static HTML.

#3530
2016-01-11 17:12:47 -08:00
John Luo c8a59d7f3e Reacting to new middleware options pattern 2016-01-08 18:07:36 -08:00
Ryan Nowak 2eb6cd655b Write our ViewBuffer values asynchronously 2016-01-08 17:12:27 -08:00
Pavel Krymets 57bf12311b Revert DependencyContext changes untill dotnet-cli packages get sorted out 2016-01-08 15:59:53 -08:00
Pavel Krymets 566790577d Add dependency context fallback to razor view compilation 2016-01-08 13:43:52 -08:00
Ajay Bhargav Baaskaran 0bb772a815 [Fixes #3755] Added logging for view compilation 2016-01-08 11:58:09 -08:00
John Luo c68f742dd0 Disabling hanging FlushPoint test 2016-01-08 11:56:31 -08:00
Ajay Bhargav Baaskaran bf1fcf6b56 Return BadRequest response when antiforgery token validation fails 2016-01-08 10:35:00 -08:00
John Luo 8afe28c05d Updating tests to add options to services 2016-01-07 23:54:55 -08:00
Ryan Nowak c304984a8d Fix #3501 - Issues with Flush
Calling Flush[Async]() on the writer will NOT flush the stream.
Calling Flush[Async]() in Razor will flush both the writer and the stream.

Our normal flow will be to flush the writer, but not the stream. This
avoids chunking, but allows us to do a WriteAsync on the stream as part of
the call to FlushAsync. This is done to avoid a synchronous write due to
Dispose calling Flush on the writer, which needs to call Write on the
stream.

See issue for extensive background.
2016-01-07 14:52:22 -08:00
Ryan Nowak 676bde29b9 Make Begin[Route]Form include antiforgery 2016-01-07 13:24:01 -08:00
N. Taylor Mullen 2b83dbb52e Make `ExpressionRewriter` more resilient to unconvertible types.
#3825
2016-01-07 11:41:14 -08:00
Pranav K dc878f2777 Capture exceptions thrown during compilation
Fixes #3870
2016-01-07 11:21:45 -08:00
Ryan Nowak ff00c07b85 Rename ActionDescriptorsCollection
ActionDescriptorsCollection -> ActionDescriptorCollection
2016-01-07 10:26:12 -08:00
Pranav K 9168cd1f37 Optimize allocations in Script/Link TagHelpers
Fixes #3618
2016-01-07 09:56:24 -08:00
Ryan Nowak a500a93dfb Smarter antiforgery
Adds the concept of an IAntiforgeryPolicy marker interface as well as
the ability to overide policy with a 'closer' filter.

Adds a new [IgnoreAntiforgeryToken] attribute for overriding a scoped
antiforgery policy.

Adds a new [AutoValidateAntiforgeryToken] attribute (good name tbd) for
applying an application-wide antiforgery token. The idea is that you can
configure this as a global filter if your site is acting as a pure
browser-based or 1st party SPA. This new attribute only validates the
token for unsafe HTTP methods, so you can apply it broadly.
2016-01-05 17:24:33 -08:00
Pranav K 0a2b6205c9 Reacting to Routing changes 2016-01-05 12:05:20 -08:00
Ryan Nowak 4141fcae69 Optimize MvcRouteHandler
- Check MVC services once at startup
- Make action selector sync

We've never really had a scenario for the action selector being async, it
just ended up that way. None of our extensibility here lets you do
anything async without replacing it wholesale, which we don't
recommend.
2016-01-05 11:31:43 -08:00
Ajay Bhargav Baaskaran 47a3aee2c1 [Fixes #3361] Changed the value provider preference to be backwards compatible 2016-01-04 12:55:35 -08:00
Ajay Bhargav Baaskaran 1f87442092 [Fixes #3749] Expose ActionContext on IUrlHelper 2016-01-04 10:33:42 -08:00
Doug Bunting 568b061441 Mock `HttpContext`, not `DefaultHttpContext`
- build break
- recent HttpAbstractions changes made `DefaultHttpContext` harder to mock (would need `CallBase=true`)
2016-01-03 14:25:42 -08:00
Pranav K 7d5a68b9ae Reacting to IHtmlContentBuilder changes 2015-12-31 11:52:26 -08:00
Ryan Nowak 51564d04c0 Remove a test that tests Dictionary
This test is coupled to Dictionary<>'s error message. We don't need this.
2015-12-30 16:55:51 -08:00