不允许加载本地资源:
我想流在线video..但我面临j查询错误不允许加载本地资源: …我找到很多解决方案,但这一切都不适合我。 这是我的代码……
控制器== >>>
public ActionResult PlayVideo(string VidPath) { ViewData["VidPath"] = VidPath; return View(); }
查看== >>>
我有同样的问题。 每当我使用Server.MapPath
或Path.GetFullPath
或只是硬编码“〜/ Content / images / image.jpg”时,我总是得到相同的错误不允许加载本地资源。
它为我工作的唯一方式是当我使用“Content / images / image.jpg”时没有
〜/
在开始
所以我的解决方法是这样的
var imageName = Path.GetFileName(image); var parentImage = Directory.GetParent(image); var parentOrder = Directory.GetParent(parentImage.FullName); var parentDate = Directory.GetParent(parentOrder.FullName);
它有点乱,但它对我有用。 或者,您也可以在ViewModel中传递Variable路径以使代码更清晰。
如果有人知道更好的解决方案,请在此处发布,以便人们知道正确的答案。