From some time ago I started making all my websites AngularJS, WebAPI powered. It gives me more control over the traditional ASP.NET MVC approach (also some more problems) but also provides a way to give RESTful API access to other apps.
Below is the simplest controller for downloading files, of course I don't suggest doing anything like this without some try/catch blocks and referencing a file path as args to controller.
Short explanation:
- response should emit Http status 200 to indicate that the request was properly carried out
- Http header field Content-Disposition "suggests" a browser of default file name when downloading, this is not part of the HTTP 1.1 standard but it's widely used, you can read all about it on Stackoverflow
No comments:
Post a Comment