How to stream an MP3 from an ASP.NET MVC Controller Action

前端 未结 7 1635
时光说笑
时光说笑 2020-12-29 16:31

I have an mp3 file in my site. I want to output it as a view. In my controller I have:

public ActionResult Stream()
{
        string file = \'test.mp3\';
            


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 17:19

    If your MP3 file is in a location accessible to users (i.e. on a website folder somewhere) you could simply redirect to the mp3 file. Use the Redirect() method on the controller to accomplish this:

    public ActionResult Stream()
    {
        return Redirect("test.mp3");
    }
    

提交回复
热议问题