简体   繁体   English

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

[英]getting error “Unknown Server error” while using asyncfileupload in asp.net using c#?

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 : 现在一切都在我的本地主机上工作正常...但是当我在托管服务器上上传此文件时,当我上传文件时出现错误..错误是:

"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 ?? 那么它应该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
 }

This problem you facing because of code-behind file is not found. 找不到由于代码隐藏文件而导致的此问题。 check whether you are missing any code-behind files 检查是否缺少任何代码隐藏文件

The problem is due to the fact of the server file not being shared to IIS. 问题是由于服务器文件未共享到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. 右键单击您要保存文件的文件夹,导航到安全设置,然后添加/允许ILS / USERS修改该文件夹。 This will solve your problem. 这样可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM