Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: [Regression]Required attribute on string property is not honored when request is sent as string content [1039]

$
0
0
Build - May 8th
My model

public class ValidationModel
{
public int Id { get; set; }

[Required]
[Range(1,10)]
public int IntReq { get; set; }

[Required]
public int IntNotReqAndDMIsReq { get; set; }

[Required]
public string StrNotReqAndDMIsReq { get; set; }
}

I am making following request
var jsonEncodedBadObject = "{\"Id\": 4}";
object mediaTypeFormatter = "application/json";
request.Content = new StringContent((string)jsonEncodedBadObject, System.Text.Encoding.UTF8, (string)mediaTypeFormatter);

I am seeing following errors when I get a response
Key=model
Value
Exception:Required property 'IntReq' not found in JSON. Path '', line 1, position 9.
Exception:Required property 'IntNotReqAndDMIsReq' not found in JSON. Path '', line 1, position 9.


When I used April 25th build, I am seeing missing string property in Json errors too.

I am seeing
Key=model
Value
Exception:Required property 'IntReq' not found in JSON. Path '', line 1, position 9.
Exception:Required property 'IntNotReqAndDMIsReq' not found in JSON. Path '', line 1, position 9.
__Exception:Required property 'StrNotReqAndDMIsReq' not found in JSON. Path '', line 1, position 9.__

I attached fiddler session. 1st one is April 25th build and 2nd one is latest build

If you have add DataContract attribute to class and [DataMember(IsRequired = true)] on string property, you see following in response

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>