zoukankan      html  css  js  c++  java
  • HttpPostedFileBase always null when upload file by asp.net mvc4 mobile

    困扰了很久的问题,终于解决了,解决方案连接:

    http://stackoverflow.com/questions/13292173/asp-net-mvc-razor-uploading-file-httppostedfilebase-always-null

    @using(Html.BeginForm("Import","Home",FormMethod.Post,new{ enctype ="multipart/form-data"})){<input type="file" name="uploadFile"/><input type="submit" value="Importa"/>}
    

      

    [AcceptVerbs(HttpVerbs.Post)] // or [HttpPost], nothing changes
    public ActionResult Import(HttpPostedFileBase uploadFile)
    {
       Debug.WriteLine("Inside Import");
       if (uploadFile == null)
           Debug.WriteLine("null");
       // Verify that the user selected a file
       if (uploadFile != null && uploadFile.ContentLength > 0)
       {
          Debug.WriteLine("Valid File");
          ...
       }
    }
    

      


    需要在View中添加
    @data_ajax="false"



    呼,舒服~
  • 相关阅读:
    Spark安装
    JavaScript encodeURIComponent()
    Kafka分布式:ZooKeeper扩展
    Kafka特性
    Kafka消息topic分区
    Kafka消息文件存储
    哈希表
    sizeof
    pytest_demo_实战2_fixture应用
    pytest_demo_实战1
  • 原文地址:https://www.cnblogs.com/4kapple/p/2975244.html
Copyright © 2011-2022 走看看