MVC本地上传EXCEL并分析存入数据库正常,发布到IIS后报错:未在本地计算机上注册“Microsoft.Jet.Oledb.4.0。原因是VS调试时模拟的是32位,发布后的IIS是64位。
需要到IIS设置对应的应用池。将 高级设置中的 启用32位应用程序 从false改为true.

public string GetUploadPath(HttpPostedFileBase file)
{
string fileNameR;
string savePath;
if (file == null || file.ContentLength <= 0)
{
//ViewBag.error = "文件不能为空";
return null;
}
else
{
string filename = Path.GetFileName(file.FileName);
int filesize = file.ContentLength;//获取上传文件的大小单位为字节byte
string fileEx = Path.GetExtension(filename);//获取上传文件的扩展名
string NoFileName = Path.GetFileNameWithoutExtension(filename);//获取无扩展名的文件名
int Maxsize = 4000

在MVC应用中,本地环境上传并解析Excel到数据库功能正常,但部署到IIS后出现错误:未注册'Microsoft.Jet.Oledb.4.0'。问题在于VS调试时使用32位环境,而IIS默认为64位。解决办法是在IIS中修改应用池设置,启用32位应用程序为true。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



