MVC : using Json pass int value


This's article to see, how to pass int value to MVC controller as parameter, by using Json post. So, we should use Nullable for int as parameter, in that case, if you passing value is not int, like empty, or string value. It won't throw exception error at .net.

1. C#, how to define Json at Controller(int and nullable int)

2. Client Side Jquery Post

3. use int'll throw exception error at .net

It'll throw exception when you pass value is not int

4. result(int and nullable int)

basically, parameter is int'll failed. We shouldn't use that when you want to pass int. On the other hand, you should use int? or Nullable int, at that case, if it's not int, don't throw exception error and pass null to server side.