Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
public ActionResult Index()
       {
           var file = Server.MapPath("~/app_data/ipl.mp3");
           return File(file, "audio/mp3");
           return View(db.Notes.ToList());

       }



How to correct this code i have to return both statement on page load but it works individually?
Posted
Updated 1-Jun-14 21:20pm
v3

1 solution

I would pass a reference to the file on the server in the model or viewbag

Then in the view, on the page ready event intiate the file download or whatever you are trying to do with it.

e.g.
C#
public ActionResult Index()
       {
           viewbag.filepath = Server.MapPath("~/app_data/ipl.mp3");
           return View(db.Notes.ToList());

       }


in the view, you can then access the file path via the viewbag.filepath
 
Share this answer
 
v2

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