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

前端 未结 7 1545
时光说笑
时光说笑 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");
    }
    
    0 讨论(0)
提交回复
热议问题