【发布时间】:2014-09-18 01:33:43
【问题描述】:
在下面测试我的代码时,如下所示:
http://localhost:49494/api/DownloadFile/q%3a%5cLetters%5cOnlineReminder.pdf
导致此异常:
检测到来自客户端的潜在危险 Request.Path 值
像这样:
http://localhost:49494/api/DownloadFile?q%3a%5cLetters%5cOnlineReminder.pdf
函数中的文档路径(FullPath)为空。
代码如下:
[HttpGet]
[Route("api/DownloadFile/{*FullPath}")]
public IHttpActionResult DownloadFile(string FullPath)
{
if (FullPath == null)
return NotFound();
System.IO.MemoryStream Stream = _ArchiveRepository.GetDownloadStream(FullPath);
return new MemoryStreamResult(Stream, "application/octet-stream");
}
我也编写了一个 MemoryStreamresult。
【问题讨论】:
标签: c# asp.net-web-api