我在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
我该如何解决这个问题?
它会创建类似于“http:// localhost:49823/BusinessCaseHistory/Details /〜%2fHistory%2f132%2f18%2faagn%258ab.TIF”的内容,导致HTTP Error 400 - Bad Request。 – user2185692 2013-03-19 09:31:16
对,那么你将不得不编码字符串的名称部分 – Dima 2013-03-19 09:36:47
这次它给了我'http:// localhost:49823/History/132/18/aagn%258ab.TIF',然后HTTP Error 400 - 错误的请求。如果文件名被修改,那么它就不能被找到。我担心我必须重新命名数据库中的所有文件和记录(其中约有40万)。 – user2185692 2013-03-19 09:48:07