JqGrid doesn't work in ASP.NET MVC2
I have a project in ASP.NET MVC1 using VB.NET controlers and JqGrid. it works fine under MVC1. After migrating the project to ASP.NET MVC2, the grid is no longer populated. It seems tha开发者_如何学Ct there is some new restrictions on returned Jsonresult in MVC2. How to solve this in VB.NET. Controler function populating the jqgrid is something like this :
Function GetGridRecordset(ByVal qry As String) As JsonResult
Dim result = New JsonResult()
...
...
Return result
End Function
Is there anyone who have a solution?
In Asp.net MVC 2 JsonResult only responds to http Post.
http://www.asp.net/learn/whitepapers/what-is-new-in-aspnet-mvc/#_TOC5
here is a post about why Get is not supported for Json
http://haacked.com/archive/2009/04/02/anatomy-of-csrf-attack.aspx
In MVC2 : Dim result = New JsonResult() make by default result.JsonRequestBehavior = JsonRequestBehavior.DenyGet while this was not the case in MVC1. The response is :
Function GetGridRecordset(ByVal qry As String) As JsonResult
Dim result = New JsonResult()
...
...
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet
Return result
End Function
Now, jqGrid works fine under MVC2 without modifying anything on the client side code.
I would need to see more code but could this be down to the changes in JsonResult in MVC 2? you may need to allow the GET verb by setting the JsonRequestBehavior Property to JsonRequestBehavior.AllowGet
精彩评论