如何做一个ASP.NET MVC Ajax表单后用的multipart / form-data的? [英] How to do a ASP.NET MVC Ajax form post with multipart/form-data?

查看:522
本文介绍了如何做一个ASP.NET MVC Ajax表单后用的multipart / form-data的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.NET MVC的网站有一个表单,允许文件上传使用上,像这样的表单标签多部分/表单数据加密类型选项

 <表单的enctype =的multipart / form-data的方法=邮报行动='<%= Url.Action(邮报,项,新{ ID = ViewData.Model.MemberDetermination.DeterminationMemberID})%GT;'>

如何将我写这篇文章做一个ASP.NET MVC Ajax表单后呢?


解决方案

  1. 您可以使用一些额外的上传者(如 jQuery的多文件上传) (我preFER这种方式和我preFER不使用MS阿贾克斯)

  2. 使用:

      AjaxHelper.BeginForm(邮报,项,新{ID = ViewData.Model.MemberDetermination.DeterminationMemberID},新AjaxOptions(){/ *某些选项* /},新{ENCTYPE =的multipart / form-data的})


但在第二种情况下,我不知道它会工作。

I am working on a ASP.NET MVC web site which has a form that allows for the upload of files using the multipart/form data enctype option on the form tag like so

<form enctype="multipart/form-data" method="post" action='<%= Url.Action("Post","Entries",new {id=ViewData.Model.MemberDetermination.DeterminationMemberID})  %>'>

How would I write this to do an ASP.NET MVC Ajax form post instead?

解决方案

  1. You can use some additional uploaders (e.g. jQuery multiple file uploader) (I prefer this way and I prefer not to use MS Ajax)
  2. Use:

    AjaxHelper.BeginForm("Post", "Entries", new {id=ViewData.Model.MemberDetermination.DeterminationMemberID}, new AjaxOptions(){/*some options*/}, new {enctype="multipart/form-data"})
    

But in second case I'm not sure that it will work.

这篇关于如何做一个ASP.NET MVC Ajax表单后用的multipart / form-data的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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