开发者

ASP.Net MVC 3 WebFormsViewEngine HTML Helpers and JSON data

I would like to know if is possible in ASP.Net MVC 3, using Web forms view开发者_开发知识库 engine and HTML Helpers, and the client side we are using Ext.Js to generate the grids.

The problem is when I return JSON(data) for the Ext.JS grid and the HTML Helper. The HTML Helper is not able to render the JSON element. It pops-up a window asking "What firefox should do with this file?".

I've tried to use:

return this.Json(new { objectJson = object}, "text/html", JsonRequestBehavior.AllowGet);

And it returned a new page with the HMTML Code, didn't bind to the HTML Helpers. I also tried without the JsonRequestBehavior.AllowGet and the result was:

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

And even if I change the MIME type of the Header to application/json and make the method's return as JSONResult instead of ActionResult it still doesn't recognize the file.

return this.Json(new { IssueInventoryPartModel = issueInventoryPartmodel, success = true }, "application/json", JsonRequestBehavior.AllowGet);

Briefly the question is: The HTML Helper for Web Form View Engine binds with JSON?

Best regards,

Tito


I had this problem while sending html data via json, and solved it by adding contenttype to the jsonresult, in the server side action method (called via js in client side), there should be something like :

return Json(dataToReturn, "text/html")


it sounds like the content-type for the action result is not being set properly


how about including JsonRequestBehavior.AllowGet on the return of the JSON as in:

return Json(new
            {
                data = components,
                success = true
            }, JsonRequestBehavior.AllowGet);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜