得到错误“未知服务器错误”;同时使用C#在asp.net中使用asyncfileupload? [英] getting error "Unknown Server error" while using asyncfileupload in asp.net using c#?

查看:83
本文介绍了得到错误“未知服务器错误”;同时使用C#在asp.net中使用asyncfileupload?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 :

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

这是代码:

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"

我应该怎么做...我也在使用updatepanel ...但是我不确定会导致此问题..

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

更新:-

所以当我第一次遇到问题时,它是一个代码隐藏问题...
这就是我现在在做什么:

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" %>

我应该尝试:

CodeBehind:"Admin.aspx.cs" 

然后应该做什么继承

任何帮助都是真正的帮助

any help will be real helpfull

更多更新

我的.cs代码以这样的方式开始:

my .cs code starts like this :

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


推荐答案

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

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.

这篇关于得到错误“未知服务器错误”;同时使用C#在asp.net中使用asyncfileupload?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆