asp.net - 在 OpenFileDialog 中的 asp.net
问题描述
我正在通过 asp.net 创建一个 Web 服务器。源代码在调试模式下运行良好。但是,发布到 iis 后,如果通过源,大约 20 秒后会出现错误“HTTP 错误 503。服务不可用”。我确信 OpenFileDialog 部分存在错误。过去,此代码在发布后运行良好。我不知道从那以后修改了什么。
在此先感谢您的帮助。
.js 代码
action: function (e, dt, node, config) {
$.ajax({
"url": "/api/Member/ExcelRead",
"type": "POST",
"datatype": 'json',
success: function (data) {
if (data === 'OK') {
alert("성공");
}
},
error: function (response, state, errorCode) {
alert("실패");
}
});
。CS
public class MemberController : ApiController
{
[HttpPost]
public string ExcelRead()
{
ExcelHelper helper = new ExcelHelper();
Thread th = new Thread(helper.ReadExcelData);
th.SetApartmentState(ApartmentState.STA);
th.Start();
th.Join();
if (helper.data == null)
return ("NO");
return ("OK");
}
}
public void ReadExcelData()
{
IsRun = false;
OpenFileDialog openFile = new OpenFileDialog();
openFile.DefaultExt = "xlsx";
openFile.Filter = "Excel Files(*.xlsx)|*.xlsx";
DialogResult dresult = openFile.ShowDialog();
if (dresult != DialogResult.OK)
{
return;
}
if (openFile.FileNames.Length > 0)
{
foreach (string filename in openFile.FileNames)
{
//this.textBox1.Text = filename;
}
}
}
解决方案
推荐阅读
- php - Yii2 获取数据库查询结果的问题
- python - Python:在 min(list) 中返回 0,没有最小值为 0
- python - Python:“如果 i.find('a')['id'] is not None:”返回 TypeError 'NoneType' 对象不可下标,但 print() 返回一个值
- java - 使用 DTO 的发布方法
- python - 按 (K,V) 对减少并按 V 排序
- android - Android 中的影子
- php - 如何根据值查找数组 ID
- xml - 从 XML 值中删除引号
- c# - AutoMapper + 可空外键 + Entity Framework Core
- c - 致命错误 C1083:无法打开包含文件:'sys/times.h':没有这样的文件或目录