Not allowed to load local resource:

后端 未结 3 1273
天涯浪人
天涯浪人 2021-01-29 01:30

i want to stream online videos ..but i am facing j query error Not allowed to load local resource: ...i find many solution but that all did not work for me. he

3条回答
  •  执念已碎
    2021-01-29 01:39

    I had the same problem. Whenever I used Server.MapPath or Path.GetFullPath or just hardcoded "~/Content/images/image.jpg" I always got the same error Not Allowed to load local resources.

    The only way it was working for me is when I used "Content/images/image.jpg" without the

    ~/

    at the beginning

    So my workaround was like this

    var imageName = Path.GetFileName(image);
    var parentImage = Directory.GetParent(image);
    var parentOrder = Directory.GetParent(parentImage.FullName);
    var parentDate = Directory.GetParent(parentOrder.FullName);
    
    
    

    It is a little messy but it worked for me. Alternatively, you can also pass in the Variable path in a ViewModel to make a little cleaner code.

    If someone knows for a better solution please post it here so people will know the correct Answer.

提交回复
热议问题