首页 > 解决方案 > 在 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;
            }
        }
     }

标签: asp.netdebuggingopenfiledialog

解决方案


推荐阅读