我正在使用 VS 2010 开发 Web 应用程序。我将上传的图像存储在服务器的物理路径中,并在 IIS 7.5 中创建了虚拟路径(下面的屏幕截图)。在授权中,显示一个警告。对于使用 belo 代码,我尝试从服务器检索图像,但是图像不显示。问题在哪里,在虚拟路径中还是在代码中提到的路径中?
private void CallImage()
{
SqlConnection SqlCon = new SqlConnection(GetConnectionString());
SqlCon.Open();
string query = "SELECT Cmp_DocPath FROM Company_Info WHERE
Vendor_ID= '" + ddlVendorID.SelectedValue + "'";
SqlCommand SqlCmd = new SqlCommand(query, SqlCon);
SqlDataAdapter da = new SqlDataAdapter(SqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
string ImageName = Convert.ToString(dt.Rows[0][0].ToString());
Image1.ImageUrl = this.ResolveUrl("D:/Upload/Commerical Certificates/"+ImageName);
// Image1.ImageUrl = this.ResolveUrl("D:\\Upload\\Commerical Certificates\\"+ImageName);
// Image1.ImageUrl = this.ResolveUrl("~\\Upload\\Commerical Certificates\\"+ImageName);
SqlCon.Close();
}