使用c#在asp.net中使用asyncfileupload时出现错误“未知服务器错误”?

时间:2022-01-10 23:01:04

i am using asyncfileupload control to upload a .csv file an read it and store the data in database here is what i am doing :

我正在使用asyncfileupload控件上传.csv文件并读取它并将数据存储在数据库中这就是我正在做的事情:

<asp:AsyncFileUpload ID="venfileupld" runat="server" OnUploadedComplete="ProcessUpload" /> 

and here's the code:

这是代码:

protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{


    string name = System.IO.Path.GetFileName(e.FileName);
    string dir = Server.MapPath("upload_excel/");
    string path = Path.Combine(dir, name);
    venfileupld.SaveAs(path);
    writetodb(path);
    fetch4();

}

now everything is working fine in my localhost ... but when i uploaded this in a hosted server then i am getting an error when i am uploading a file .. the error is :

现在一切都在我的localhost中工作正常...但是当我在托管服务器上传这个时,我在上传文件时收到错误..错误是:

"Unknown Server Error"

what should i do ... i am using updatepanel also ... but i am not sure that will cause this ..

我该怎么办...我也在使用updatepanel ......但我不确定是否会导致这个...

UPDATE:-

so as i got the 1st ans yes its a codebehind issue ... here what i am doing now :

所以我得到了第一个答案是它的代码隐藏问题......这里我现在在做什么:

<%@ Page Title="" Language="C#" MasterPageFile="~/MainMaster.master" AutoEventWireup="true"
CodeFile="Admin1.aspx.cs" Inherits="admin1" %>

should i try :

我应该试试:

CodeBehind:"Admin.aspx.cs" 

then what should it Inherits ??

那它应该继承什么?

any help will be real helpfull

任何帮助将是真正有用的

More Update

my .cs code starts like this :

我的.cs代码如下所示:

  public partial class Admin1 : System.Web.UI.Page
{
     //all the codes
 }

2 个解决方案

#1


0  

This problem you facing because of code-behind file is not found. check whether you are missing any code-behind files

找不到因代码隐藏文件而面临的这个问题。检查您是否缺少任何代码隐藏文件

#2


0  

The problem is due to the fact of the server file not being shared to IIS. Right click on the folder you are trying to save the file to, navigate to security settings and add/allow ILS/USERS to modify the folder. This will solve your problem.

问题是由于服务器文件未与IIS共享。右键单击要将文件保存到的文件夹,导航到安全设置并添加/允许ILS / USERS修改文件夹。这将解决您的问题。

#1


0  

This problem you facing because of code-behind file is not found. check whether you are missing any code-behind files

找不到因代码隐藏文件而面临的这个问题。检查您是否缺少任何代码隐藏文件

#2


0  

The problem is due to the fact of the server file not being shared to IIS. Right click on the folder you are trying to save the file to, navigate to security settings and add/allow ILS/USERS to modify the folder. This will solve your problem.

问题是由于服务器文件未与IIS共享。右键单击要将文件保存到的文件夹,导航到安全设置并添加/允许ILS / USERS修改文件夹。这将解决您的问题。