Mozilla想要下载JSON对象 [英] Mozilla want do download JSON object

查看:53
本文介绍了Mozilla想要下载JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我有一个基于Asp.Net MVC2的项目.页面上有一个文件上传器.我使用$ .ajaxFileUpload将图像发送到控制器.

控制器有一个简单的方法,可以接受图像,进行一些计算并返回JSON对象:

Hello!

I has a project based on Asp.Net MVC2. There is a file uploader on the page. I use $.ajaxFileUpload to send image to controller.

Controller has a simple method, which accept image, do some calculations and return JSON object:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UploadMainPhoto(HttpPostedFileBase photo)
{
       ......
    return Json(new { path = "new image path" }, "text/json");
}



在IE中可以正常运行.但是Mozilla会打开保存"对话框,并提供保存JSON消息的功能.
有人知道解决方法吗?

谢谢:)



In IE it works ok. But Mozilla opens save dialog and offer to save JSON message.
Does anybody knows solution?

Thanks :)

推荐答案

.ajaxFileUpload将图像发送到控制器.

控制器有一个简单的方法,可以接受图像,进行一些计算并返回JSON对象:

.ajaxFileUpload to send image to controller.

Controller has a simple method, which accept image, do some calculations and return JSON object:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UploadMainPhoto(HttpPostedFileBase photo)
{
       ......
    return Json(new { path = "new image path" }, "text/json");
}



在IE中可以正常运行.但是Mozilla会打开保存"对话框,并提供保存JSON消息的功能.
有人知道解决方法吗?

谢谢:)



In IE it works ok. But Mozilla opens save dialog and offer to save JSON message.
Does anybody knows solution?

Thanks :)


将您的ActionResult更改为JsonResult.这样可以正确地指示内容/类型和标题,并且应该消除FF以为它是文本文件.
Change your ActionResult to JsonResult. That will direct the content/type and headers correctly and should eliminate FF thinking it''s a text file.


这篇关于Mozilla想要下载JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆