Return a FileResult
or FileStreamResult
from your action, depending on whether the file exists or you create it on the fly.
public ActionResult GetPdf(string filename)
{
return File(filename, "application/pdf", Server.UrlEncode(filename));
}
More Related Contents:
- What is ViewModel in MVC?
- How do I specify different Layouts in the ASP.NET MVC 3 razor ViewStart file?
- How can I supply an AntiForgeryToken when posting JSON data using $.ajax?
- ASP.NET MVC 3 – Partial vs Display Template vs Editor Template
- ASP.Net MVC Custom Model Binding explanation [closed]
- Handling CORS Preflight requests to ASP.NET MVC actions
- MVC 3 Model Binding a Sub Type (Abstract Class or Interface)
- How to use Bind Prefix?
- How to GetBytes() in C# with UTF8 encoding with BOM?
- MVC: How to Return a String as JSON
- How to send a model in jQuery $.ajax() post request to MVC controller method
- Using System.ComponentModel.DataAnnotations with Entity Framework 4.0
- Differences between Html.TextboxFor and Html.EditorFor in MVC and Razor
- MVC [HttpPost/HttpGet] for Action
- 404 Http error handler in Asp.Net MVC (RC 5)
- Role-based access control (RBAC) vs. Claims-based access control (CBAC) in ASP.NET MVC
- Adding a controller factory to ASP MVC
- asp.net mvc keep object alive, information
- ASP.NET MVC5/IIS Express unable to debug – Code Not Running
- maxlength attribute of a text box from the DataAnnotations StringLength in Asp.Net MVC
- Best practices for debugging ASP.NET MVC Binding
- How to compile cshtml before runtime
- CORS in ASP .NET MVC5
- how to implement ASP.NET Identity to an empty MVC project
- ASP.net MVC – Display Template for a collection
- How to reuse Areas, Controllers, Views, Models, Routes in multiple apps or websites
- Razor ViewEngine HTML.Checkbox method creates a hidden input. Why? [duplicate]
- How do I create a MVC Razor template for DisplayFor()
- Send asp.net mvc action result inside email
- Routing with and without controller name in ASP.NET MVC 4