惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
B
Blog
小众软件
小众软件
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
I
InfoQ
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
H
Help Net Security
雷峰网
雷峰网
S
SegmentFault 最新的问题
V
Visual Studio Blog
爱范儿
爱范儿

博客园 - 咖啡色

拆解 Claude Code 源码:如何用软件工程思维约束 AI? 为什么要在.Net Core中使用MediatR library? Let’s Encrypt 项目计划自动化地提供免费的 CA 证书 论C#逼格手册 这些.NET开源项目你知道吗?让.NET开源来得更加猛烈些吧!(第二辑) Entity Framework where语句起作用的真正用法 ASP.NET Page_Load执行两次 .NET:在ASPX、ASHX和MVC中使用IOC容器(菜鸟必看) [转]SqlServer 表分区详细介绍 一步步构建大型网站架构 TCP/IP网络协议的通俗理解,socket,http,soap。 精妙Sql语句备忘 解决.net绘制的 WinForm 在 windows7下变形的方法 关于 ASP.net + JQuery + JQGrid + JSON.net 的简单应用(一) Entity Framework 连接 mysql 5.0出现的问题及解决方案 VSTO开发中VS2010和Office 2003的问题及解决方案 如何使用缓存提高程序性能 如何用Javascript写一个Class? 程序员装逼指南(网上看到的,笑喷了……)
HttpPostedFileBase always null when upload file by asp.ne...
咖啡色 · 2013-03-22 · via 博客园 - 咖啡色

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

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"

呼,舒服~