Commit Graph

16 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
Kevin Dockx f1e1d8f4df Initial Json Patch check-in 2015-03-23 14:46:49 -07:00
Ryan Nowak fc00aff7c5 Add TestCommon project 2015-03-16 13:49:29 -07:00
N. Taylor Mullen c1a026cbf7 Update .kproj => .xproj. 2015-03-11 14:01:43 -07:00
N. Taylor Mullen df4b92b1c1 Update MVC projects to utilize Common repo classes.
- Had to add extra dependencies to work around aspnet/XRE#1237.
- Updated src and test projects.
2015-02-22 18:23:28 -08:00
Yishai Galatzer bb31e2aec5 Rename Microsoft.AspNet.PageExecutionInstrumentation to Microsoft.AspNet.PageExecutionInstrumentation.Interfaces 2015-02-19 12:02:29 -08:00
Pranav K 5ed0638402 Move PageExecutionListener interfaces to a separate assembly. 2015-02-11 18:06:20 -08:00
damianedwards 3d33418f31 Add the LinkTagHelper:
- #1580
2015-02-03 10:12:38 -08:00
Anthony Sneed 1118315a9d [Resolves #1887] XmlDataContractSerializer Input and Output Formatter Tests Cleanup. 2015-01-30 10:02:33 +01:00
Pranav K a452205e60 Moving Microsoft.AspNet.Mvc.Xml to src dir 2015-01-29 10:28:40 -08:00
Pranav K fde1b13b4a Updating Mvc.NoFun.sln 2015-01-29 10:26:38 -08:00
damianedwards 759fbbd661 Added the EnvironmentTagHelper:
- #1553
2015-01-22 10:17:25 -08:00
Chris Ross 91d7e382d1 Consume new strongly typed headers. Remove temp implementations. 2015-01-14 15:51:34 -08:00
Pranav K f649fb45c8 Adding TestConfiguration to NoFun.sln to avoid it from modifying the sln
on open
2015-01-05 13:42:41 -08:00
Ryan Nowak f66345263d Add WebApiCompatShim project structure 2014-10-10 13:41:35 -07:00
NTaylorMullen be4a6c8d98 Split FunctionalTests from Mvc solution.
- Created a solution that had everything the Mvc.sln had EXCEPT functional tests.
- Added Mvc.NoFun.sln.

#1227
2014-10-09 12:18:30 -07:00