首页 > 解决方案 > 在 html 音频播放器标签中编码和解码 #,& 和 + 符号

问题描述

我有一个 Angular 6 应用程序,其中有一些 html 音频播放器部分。我已经通过标签对mp3文件进行了编码encodeURIComponent并在其中使用。src以下播放器的音频播放正常

<audio controls>
  <source src="www.test.com/api/downloadaudio?filename=test.mp3" type="audio/mp3">
</audio>

对于像 #, & 和 + 这样的特殊符号,它按照如下方式编码encodeuricomponenet并应用在源标签中,如下所示

文件名 -Test#1.mp3
文件名 -Test&2.mp3
文件名 -Test+1.mp3

<audio controls>

  <source src="www.test.com/api/downloadaudio?filename=test%231.mp3" type="audio/mp3">

  <source src="www.test.com/api/downloadaudio?filename=test%262.mp3" type="audio/mp3">

   <source src="www.test.com/api/downloadaudio?filename=test%2B3.mp3" type="audio/mp3">

在 API 端(C#)它没有被正确解码。我在 C# 端得到以下值

对于 1,2 和 3 case-> test是我得到的文件名值,而不是test#1, test&2,test+3

让我知道这里做错了什么......

谢谢,

塞尔瓦

标签: c#audiodecodeurlencodeencodeuricomponent

解决方案


推荐阅读