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

Commented Unassigned: Parameters binding [1453]

$
0
0
Hi,

I'm actually migrating from MVC 3 to MVC 4 and I'm confronted to a weird issue.

All this was working well on MVC3, and an empty MVC4 project can easily reproduce this issue.

I have a controller containing this action :

```
public JsonResult Edit(int id, string name, int criticality, DateTime? end, Dictionary<Guid, string> conditions, Dictionary<Guid, string> exceptions)
```

I'm calling this directly in JSON (this can be dopne with Fiddler also).
The following calls are working well.

```
Host: localhost:13497
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
Content-Type: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Content-Length: 222

{"name":"test","criticality":32,"end":null,"conditions":[{"Key":"de7ddf71-0a60-4c33-804d-287d3b8d48d2","Value":"[\"Value\"]"}],"exceptions":[{"Key":"de7ddf71-0a60-4c33-804d-287d3b8d48d0","Value":"[\"Value2\"]"}]}

```
OR

```
Host: localhost:13497
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
Content-Type: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Content-Length: 155

{"name":"test","criticality":32,"end":null,"conditions":[{"Key":"de7ddf71-0a60-4c33-804d-287d3b8d48d2","Value":"[\"Value\"]"}],"exceptions":null}
```


But when I provide an empty dictionary (Count = 0), MVC throw a CAST exception.

```
Host: localhost:13497
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
Content-Type: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Content-Length: 87

{"name":"test","criticality":32,"end":null,"conditions":[],"exceptions":null}
```

Modifying the Dictionary<Guid, string> to Dictionary<string, string>, I can see that MVC4 is trying to map the routing parameters to my Dictionary :

![Image](http://social.msdn.microsoft.com/Forums/getfile/378345)

This behavior did not append in MVC 3. Did anyone knows why ?

Thanks.

Luc Dubrois

Par avance, merci.
Comments: Hi, Sorry for the duplicate, I did not see this previous workitem. I'll check the impact to move directly to MVC5. Thank you for your 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>