@functions{
public static string Base64String(string url)
{
try{
var location = Server.MapPath(url);
System.IO.FileStream file = System.IO.File.OpenRead(location);
System.IO.BinaryReader Binary = new BinaryReader(file);
byte[] bytes = Binary.ReadBytes(Convert.ToInt32(file.Length));
string base64String = Convert.ToBase64String(bytes);
return base64String;
}
catch{
return "";
}
}
}
输出
<video controls="controls" autoplay="autoplay" style="width:1200px;"><source src="data:video/mp4;base64,@razor.Base64String(url)" type="video/mp4"></video>