Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:http://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:
C#
[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?
Posted
Updated 31-May-15 23:40pm
v2
Comments
What is the value of tempPath?

1 solution

302 means that there is a temporary redirect and that the redirect page was found.

You requested this:
http://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 ^_^
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900