0

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

3 Answers 3

1

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")
Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately in my case it returns only plain HTML code and is not binding with the HTML Helper. It creates a new page and append the new returned HTML code on the top of the page.
0

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

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.