Commit Graph

1630 Commits

Author SHA1 Message Date
Harsh Gupta 53ef8258bb The model state keys for body bound models which are bound at property will use the entire model name with this change for example
Consider

public class Person
{
    [FromBody]
    public Address Address { get; set; }
}

public class Address
{
   [Required]
   public string Street { get; set; }

   public int Zip { get; set; }
}

Request body { "Zip" : 12345 }
In this case the error key would be "prefix.Address.Street" (assuming there is a prefix because of additional metadata/positioning for/of the Person model).

public class Person
{
       [Required]
       public string Name { get; set; }
}

public void Action([FromBody]Person p)
{
}
Request body { }
In this case the prefix gets ignored and the error key is Name.
Please note this is so that we are compatible with MVC 5.0

public class Person
{
       [Required]
       public string Name { get; set; }
}

public void Action([FromBody][ModelBinder(Name = "prefix")] Person p)
{
}

public void Action2([FromBody][Bind(Name = "prefix")] Person p)
{
}
Request body { }
In both these cases (Action and Action2) the prefix gets ignored and the error key is Name.
This is a slight improvement from mvc, as in MVC the action parameter would be null.

The followup for this would be to fix #2416 -
This PR ignores the validation assuming that #2416 will address the issues and update the test.

NOTE: previous versions of mvc did not have property binding and hence there is no precedence in this case. For MVC and Web API it was possible to body bind an action parameter which used an empty prefix instead of a parameter name for adding errors to model state (In case of MVC if a custom prefix was provided, it failed binding from body i.e the parameter was null).
2015-04-22 14:02:08 -07:00
Kirthi Krishnamraju 924d50bd8f Added functionaltests for JsonPatchDocument 2015-04-22 13:44:25 -07:00
Kirthi Krishnamraju 3042a62ba9 Removed Test operation code and changed T to TModel 2015-04-22 13:44:20 -07:00
Kirthi Krishnamraju bf712263fc Fix for #2280 - Cannot do an "add" patch to IList<Anything>
Added unit tests
2015-04-22 13:44:14 -07:00
Kirthi Krishnamraju e48565dcd8 Adding errors in ModelState 2015-04-22 13:44:09 -07:00
Kirthi Krishnamraju 9f97d25e02 Moved exception messages to resource file and updated tests to validate exception messages 2015-04-22 13:44:04 -07:00
Hao Kung a001cd4f2a React to Security logging change 2015-04-22 12:51:19 -07:00
Ryan Nowak f3679f214e Fix #1712 - remove reflection from validation code in MutableObjectModelBinder
This change moves [BindingBehavior(...)] and friends into the model
metadata layer, and removes the reflection code from
MutableObjectModelBinder that was looking for them previously.
2015-04-22 12:10:45 -07:00
Kirthi Krishnamraju 9d2b1822d9 Fix for #819 : Attribute Routing: Resolve Name + Token Replacement 2015-04-22 11:47:23 -07:00
Henk Mollema 92554fa634 Utilize `nameof` operator 2015-04-22 10:57:50 -07:00
Chris Ross 7b7667e338 Fix DataProtection dependency. 2015-04-22 10:23:36 -07:00
Henk Mollema 323ec2fdc7 Throw exception with unknown attributeName
Throw a meaningful exception if the attribute to copy does not exists
in the attributes of the TagHelperContext rather than:
`System.InvalidOperationException : Sequence contains no matching
element`.

Added test too.
2015-04-21 14:49:14 -07:00
Kiran Challa 162c4709c1 Refactor attribute route 2015-04-21 11:02:05 -07:00
sornaks 064c01cf2b #2267 - Moving responsibility for setting ModelState.MaxAllowedErrors into a more appropriate location. 2015-04-20 14:31:04 -07:00
Ryan Nowak 8bae02928d Fix build break 2015-04-20 12:44:30 -07:00
Eilon Lipton dedf923f09 Merge pull request #2399 from henkmollema/fix-1764
Removed clear-text password from sample
2015-04-20 09:25:07 -07:00
Ryan Nowak 2719111453 Add more details to ModelAttributes
This change adds more information to ModelAttributes, so that metadata
providers can look at the attributes on the property and type separately
if so desired
2015-04-17 17:35:20 -07:00
Ajay Bhargav Baaskaran a4fd51772f [Fixes #2276] Serialize only simple types to session in TempData 2015-04-17 14:30:47 -07:00
Pranav K fb451b51e5 Added SourceLocation to inherited chunks \ tag helpers
Updated CompilationResult to support compilation failures from multiple
files.

Fixes #2321
2015-04-17 11:23:38 -07:00
Ajay Bhargav Baaskaran f878ca5b15 [Fixes #1919] Added path info to RazorPage exceptions 2015-04-17 10:30:37 -07:00
ianhong 21031a3aa8 Add sample and functional test for custom inline constraints 2015-04-17 08:42:20 -07:00
Henk Mollema 3ac6acdab4 Removed clear-text password from sample
Removed unused clear-text password as it encourages risky coding.

#1764
2015-04-17 13:58:48 +02:00
Kiran Challa e7728dde3f Log view discovery 2015-04-17 04:23:45 -07:00
Pranav K 18efefd5cf * Use PropertyHelper.SetValue in DefaultControllerActionArgumentBinder
* Update DefaultModelMetadataProvider to use delegates exposed on
  PropertyHelper instance.

Fixes #2355
2015-04-16 16:38:13 -07:00
Chris Ross 6223aac9be Handle Http.Core rename. 2015-04-16 15:48:27 -07:00
Kiran Challa 879057b873 Addressing minor comment from feedback 2015-04-16 12:09:42 -07:00
Ryan Nowak f77493dffe Part 1 of #1712 - Remove reflection in MutableObjectModelBinder
This change introduces a new property to ModelMetadata called
IsBindingRequired, which specifies whether or not a model value must be
present on the wire during model binding.

[DataMember(IsRequired = true)] is currently the only thing that will set
this property.

Updated tests and documentation for clarity on the difference in meaning
between MM.IsRequired and MM.IsBindingRequired. Moved setting for
IsRequired to ValidationMetadata which is a better fit.

Also added functional tests for [BindingBehavior] and [DataMember] in
model binding because they were totally missing.
2015-04-16 12:07:33 -07:00
Kiran Challa c3f10f4a0f Logging for content-negotiation 2015-04-16 12:02:55 -07:00
Kiran Challa 7576116969 Removed test code related to logging and instead used Testing repo's logging helpers. 2015-04-16 11:19:24 -07:00
Kiran Challa 65bd8c448a Removed Logging related ILogValues types and cleaned up tests. 2015-04-16 11:19:20 -07:00
Kiran Challa 20daab2fb5 Removed direct dependency on Framework.Logging and instead used Framework.Logging.Interfaces.
Fixed breaking code which additionally cleans up start-up logging which we wanted to do.
2015-04-16 11:19:17 -07:00
Henk Mollema 9eb87d4676 Removed htmlAttributes null check in GenerateForm
The null check caused the form not to use the default url generation
behavior when html attributes were specified.
2015-04-16 16:29:27 +02:00
Harsh Gupta 7f68a47fde Fixing doc comments for c67236141b 2015-04-15 14:46:29 -07:00
Harsh Gupta c67236141b Fixes 2304:
The fix splits client validation and model validation into two separate hierarchies.
Introduced ClientModelValidatorProvider in MvcOptions, which can be iterated to produce IClientModelValidators.
As a result of this, HtmlGenerator code can be free of ActionBindingContext and directly consumes options.
This also means that we do not modify the client validations during resource filters.
2015-04-15 14:30:46 -07:00
N. Taylor Mullen eaa58bc913 Change inject directive to format correctly after newline during design time.
- Also modified existing tests to account for aspnet/Razor#332 which fixed models formatting after newline.
- Updated tests for inject to understand new formatting parsing.

aspnet/Razor#332
2015-04-15 12:18:45 -07:00
Ajay Bhargav Baaskaran 4951235eef [Fixes #2337] Added support for file types in input taghelper and
htmlhelper
2015-04-15 11:58:40 -07:00
Ajay Bhargav Baaskaran a9f2c937df React to Cookie changes 2015-04-15 11:50:11 -07:00
Hao Kung bee20973c7 React to http challenge changes 2015-04-15 11:39:12 -07:00
Youngjune Hong 9daf6b48a1 Update ModelBinderAttribute not throw exceptions from BinderType property setter 2015-04-14 17:31:50 -07:00
Youngjune Hong 852d6402eb Remove an unecessary test from DefaultAssemblyProviderTests 2015-04-14 16:00:10 -07:00
N. Taylor Mullen 2c4c35e126 Add rendering logic for PreElement and PostElement on TagHelperOutput.
- Added unit tests to validate that the properties were rendered correctly.
- Modified functional tests to utilize PreElement and PostElement.

aspnet/Razor#341
2015-04-14 12:01:20 -07:00
Ryan Nowak d0e5118741 Delay Attribute Route initialization to the first request 2015-04-13 16:16:27 -07:00
Kiran Challa 24b930fa7c Clean up logging.
- Removing scopes as we want to limit the number of scopes being created.
- Added new log statements using the new log format string.
2015-04-13 15:59:38 -07:00
sornaks 7ea467f73d Adding functional test for CacheTagHelper's enabled property. 2015-04-09 13:21:47 -07:00
Doug Bunting 8965ac96c0 Add more functional tests of cache profiles 2015-04-08 22:37:45 -07:00
Harsh Gupta 58a5ad2279 Adding Outputformatter in resource filters. 2015-04-08 16:46:46 -07:00
Ajay Bhargav Baaskaran f60896bd90 [Fixes #2259] Use fast property setter in MutableObjectModelBinder 2015-04-08 16:44:30 -07:00
Victor Hurdugaci 5164d647c5 React to resource renames 2015-04-08 15:27:51 -07:00
sornaks 645b82d194 Fixing the build break. 2015-04-08 14:30:19 -07:00
sornaks b08a2154c1 #2142: Introducing enabled attribute for CacheTagHelper. 2015-04-08 13:27:03 -07:00