错误如题:出现错误原因:
上传 很多文件 后缀名是不一致的 但是 在下载的时候 后缀名为 .config .log .bat .ini 就会出现错误,所报的错误就是 远程服务器返回错误: (404) 未找到。代码如下:
/// <summary>
/// 异步升级
/// </summary>
private void DownloadAllFiles()
{
try
{
//判断是否能连接服务器
ulc.GET_CONN();
string filename = dt.Rows[downfilenum]["文件"].ToString();
string filepath = dt.Rows[downfilenum]["客户端路径"].ToString();
string serverpath = "http://" + ConfigHelper.GetConfigString("ServerIP") + "/upgrade/";
serverpath = serverpath + filename;
string localFilePath = Path.Combine(this.UpdateFolderPath, filename); webClient.DownloadFileAsync(new Uri(serverpath), localFilePath);
gridView1.SetRowCellValue(downfilenum, "下载状态", "正在下载...");
}
catch (Exception ex)
{
Directory.Delete(Application.StartupPath + @"\update", true);
Directory.CreateDirectory(Application.StartupPath + @"\update");
MessageHelper.Show("连接不上服务器!", MessageType.Information);
updateFlaglbl.Text = "下载失败";
startbtn.Enabled = true;
}
}我想问问 这是什么原因呢 是要在哪里需要设置么 设置文件下载的类型我要补充的是 上传没有问题的 已经成功上传到指定文件夹。求解!
上传 很多文件 后缀名是不一致的 但是 在下载的时候 后缀名为 .config .log .bat .ini 就会出现错误,所报的错误就是 远程服务器返回错误: (404) 未找到。代码如下:
/// <summary>
/// 异步升级
/// </summary>
private void DownloadAllFiles()
{
try
{
//判断是否能连接服务器
ulc.GET_CONN();
string filename = dt.Rows[downfilenum]["文件"].ToString();
string filepath = dt.Rows[downfilenum]["客户端路径"].ToString();
string serverpath = "http://" + ConfigHelper.GetConfigString("ServerIP") + "/upgrade/";
serverpath = serverpath + filename;
string localFilePath = Path.Combine(this.UpdateFolderPath, filename); webClient.DownloadFileAsync(new Uri(serverpath), localFilePath);
gridView1.SetRowCellValue(downfilenum, "下载状态", "正在下载...");
}
catch (Exception ex)
{
Directory.Delete(Application.StartupPath + @"\update", true);
Directory.CreateDirectory(Application.StartupPath + @"\update");
MessageHelper.Show("连接不上服务器!", MessageType.Information);
updateFlaglbl.Text = "下载失败";
startbtn.Enabled = true;
}
}我想问问 这是什么原因呢 是要在哪里需要设置么 设置文件下载的类型我要补充的是 上传没有问题的 已经成功上传到指定文件夹。求解!
<add path="*.config" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/>
更多的内容可以参考Web.config的详解和Asp.NET底层解密:http://msdn.microsoft.com/zh-cn/library/bb398986(v=vs.100).aspx
在网上找了很多资料 使用限制的 说iis 不允许这样的 需要在iis上上把config这个后缀去掉 就可以了 具体操作方法是这样的 你看一下对不对如果是iis6右键网站属性---》主目录---》编辑
在缓存ISAPI的应用程序扩展名中删除.config 项目
ASP.NET IIS映射(IIS->默认网站->属性->主文档->配置->映射->添加):可执行文件C:"WINDOWS"Microsoft.NET"Framework"v2.0.50727"aspnet_isapi.dll扩展名.config
这种方法试过了 不好使
按照说法做,在服务器上打开iis,找到自动升级的文件夹,查看属性,选择”HTTP头“选项卡,发现有个MIME映射选项,单击”文件类型“,再单击”新类型”,在关联扩展名里添加“.*”,在内容类型里添加“application/octet-stream”,设置完毕。我是按照这个添加的 结果还是不好使