我有一个用ASP.Net编写的网站。在一个页面上我有一张图片表。这些图像存储在文件夹中。有一个下拉框,显示各种文件夹名称。当用户从下拉列表中选择文件夹名称时,该文件夹中的图像将显示在表中。
问题是,一旦在下拉框中选择了文件夹,页面上的任何图像都无法在Chrome中下载。如果您右键单击图像并选择“将图像另存为..”并单击“保存”,Chrome将返回错误“中断-网络错误”。您可以单击“继续”并下载文件。您可以在新选项卡中打开图像并下载文件。它还导致页面上的所有图像无法下载,包括静态图像,如页眉上的徽标。它在Firefox中运行良好。图片相当小,大约420K。页面的代码非常简单,事实上,页面加载时的代码与从下拉框中选择项目时的代码几乎相同。这种情况发生在我们所有的网站用户身上,因此绝对不是一些插件或防病毒等。为什么从下拉框中选择文件夹可能会导致问题?以下是页面代码
`` Imports System.IO Partial Class m_Images Inherits System.Web.UI.Page Private imgPath As String Dim strFolderName As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then For Each d In System.IO.Directory.GetDirectories(Server.MapPath("~\images\ClientImages")) Dim dir = New DirectoryInfo(d) Dim dirName = dir.Name lstCategories.Items.Add(dirName) Next strFolderName = lstCategories.SelectedItem.Text.Trim imgPath = Server.MapPath("~\images\ClientImages\" + strFolderName + "\") Session("FolderName") = strFolderName Dim directoryInfo As DirectoryInfo = New DirectoryInfo(imgPath) If directoryInfo.Exists Then DataList1.DataSource = directoryInfo.GetFiles("*") DataList1.DataBind() Else DataList1.DataSource = Nothing DataList1.DataBind() End If End If End Sub Protected Sub lstCategories_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCategories.SelectedIndexChanged strFolderName = lstCategories.SelectedItem.Text.Trim imgPath = Server.MapPath("~\images\ClientImages\" + strFolderName + "\") Session("FolderName") = strFolderName Dim directoryInfo As DirectoryInfo = New DirectoryInfo(imgPath) If directoryInfo.Exists Then DataList1.DataSource = directoryInfo.GetFiles("*") DataList1.DataBind() Else DataList1.DataSource = Nothing DataList1.DataBind() End If End Sub Protected Function GetFolderName() As String imgPath = Session("FolderName") Return imgPath End Function End Class ``
尝试了不同的桌面和浏览器。这个问题仅限于Chrome(以及Opera等基于Chromium的浏览器)。该问题发生在分布在全国各地的至少50台台式机上。