我正在用 C# 创建一个 MVC3 Web 应用程序。我必须实现一个搜索屏幕来显示来自 SQL 数据库的数据以及与这些数据对应的图片。在我的详细信息页面中,我创建了指向此文档的链接:
@{
string fullDocumentPath = "~/History/" + Model.PICTURE_PATH + "/" + Model.PICTURE_NAME.Replace("001", "TIF");
}
@if (File.Exists(Server.MapPath(fullDocumentPath)))
{
<a href="@Url.Content(fullDocumentPath)" >Click me for the invoice picture.</a>
}
问题是创建文档的系统(并在数据库中添加了对其路径的引用)选择在许多文件名中使用 % 。当我有这个链接时:http://localhost:49823/History/044/00/aaau2vab.TIF
没关系。创建此链接时:http://localhost:49823/History/132/18/aagn%8ab.TIF
失败并显示:
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /History/132/18/aagn�b.TIF
我该如何解决这个问题?