【发布时间】:2017-10-15 19:05:40
【问题描述】:
我正在尝试使用input type="file" 在一个无聊的旧 HTML 页面上上传一个非常基本、简洁的文件,该页面发布到一个 .aspx 页面,两者都托管在具有 Windows 集成身份验证的 IIS(IIS7 和 IIS8)上启用(非匿名)。它在桌面版 Chrome 上运行良好,但如果我在 iPad 上使用 Chrome 或 Safari,我可以登录(以通过 Windows 身份验证)并查看表单,但如果我选择一个文件并单击发送,它只是坐下来旋转。如果我不选择一个文件,它可以正常工作。如果我从 Windows Auth 切换到 Anonymous Auth,它可以正常工作,即使在 iPad 上也是如此。我选择的文件只是来自 iPad 的照片库(最初是用内置相机拍摄的),在测试桌面版 Chrome 时,我正在测试完全相同的文件(很小,1.4M)。
这是默认的.html:
<!doctype html>
<html>
<head>
<title>Upload Test</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="upload.aspx">
<input type="file" name="foo" />
<input type="submit" value="Send" />
</form>
</body>
</html>
upload.aspx:
<%@ Page Language="C#" CodeBehind="upload.aspx.cs" Inherits="UploadTest.Upload" %>
upload.aspx.cs:
using System;
using System.Web.UI;
namespace UploadTest
{
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Response.ContentType = "text/plain";
this.Response.Write("Got here");
this.Response.End();
}
}
}
请注意,我什至没有尝试在上面访问 this.Request.Files,尽管如果我这样做了,例如:
var file = this.Request.Files["foo"];
this.Response.Write("Filename: " + (file == null ? "(no file)" : file.FileName));
...我确实看到文件名在它工作的情况下。
我没有Web.config:我只是将bin、default.html 和upload.aspx 复制到test 目录下C:\inetpub\wwwroot,然后使用IIS 管理器将其转换为具有默认设置,然后从匿名身份验证切换到 Windows 身份验证。 (但这是一个更复杂的项目的 MCVE,它确实有一个 Web.config,我只是从根本上剥离了一些东西来找出问题所在。)
回顾一下:
- 在桌面版 Chrome 中运行良好
- 如果我不选择文件,在 iPad 上也可以正常工作
- 如果我切换到匿名身份验证而不是 Windows 身份验证并做选择一个文件,则在 iPad 上工作正常
- 如果我使用 Windows Auth 并使用适用于 iPad 的 Chrome 或 Safari 选择文件,则在 iPad 上永远旋转
我不是 ASP.net 大佬。我究竟做错了什么?我需要翻转一些配置开关吗?
【问题讨论】:
标签: ios asp.net ipad iis windows-authentication