本文介绍了HTTP状态代码结果返回302 Found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码查看事务的附件。 它在我的本地计算机上运行得很好但是当我在我们的服务器上部署它时,就会出现302。我似乎无法指出哪里出错。
The code is view the attached file of the transaction. It run just fine at my local computer but when I deployed it at our server, that's when 302 found appears. I can't seem to point where it goes wrong.
Remote Address:192.168.136.7:80 Request URL:ptyisrequest-dev/DashBoard/ViewAttachment?filename=2014%5CHW14-1555_AT1.xls Request Method:GET Status Code:302 Found Cache-Control:private Content-Disposition:attachment; filename=HW14-1555_AT1.xls Content-Length:171 Content-Type:application/vnd.ms-excel; charset=utf-8 Date:Mon, 01 Jun 2015 08:57:56 GMT Location:/error/unknown?aspxerrorpath=/DashBoard/ViewAttachment Server:Microsoft-IIS/6.0 X-AspNet-Version:4.0.30319 X-AspNetMvc-Version:3.0 X-Powered-By:ASP.NET以下是我的控制器中的代码:
Here is the code in my controller:
[Authorize] [HttpGet] public FileResult ViewAttachment(string fileName) { var path = tempPath + "\\" + fileName; FileInfo file = new FileInfo(path); var mimeType = ClassHelper.GetMimeType(file.Name); return File(path, mimeType, file.Name); }有谁能告诉我如何解决这个问题?
Can anyone tell me how to fix this?
推荐答案302意味着那里是一个临时重定向,找到了重定向页面。 您要求: http:// ptyisrequest-dev / DashBoard / ViewAttachment?filename = 2014%5CHW14-1555_AT1.xls 并且服务器返回了这个: / error / unknown?aspxerrorpath = / DashBoard / ViewAttachment 看起来页面应该是返回404或其他错误代码,但网站设置意味着它只是重定向到错误页面。 如果可以,请尝试获取错误页面发出更准确的错误代码并在您的方法中处理它。 如果没有,请检查响应代码和位置。如果它是如上所述然后处理错误。 此外,通过浏览器访问该URL并查看该页面上的错误消息。 希望有帮助 Andy ^ _ ^ 302 means that there is a temporary redirect and that the redirect page was found. You requested this: ptyisrequest-dev/DashBoard/ViewAttachment?filename=2014%5CHW14-1555_AT1.xls and the server returned this: /error/unknown?aspxerrorpath=/DashBoard/ViewAttachment It looks like the page should be returning a 404 or other error code, but the sites setup means that it just redirects to an error page. If you can, try to get the error page to emit a more accurate error code and handle it in your method. If not, check the response code and location. If it is as above then handle the error. Also, visit the url through a browser and see what error message is on that page. Hope that helps Andy ^_^
更多推荐
HTTP状态代码结果返回302 Found
发布评论