0

I am a novice in ASP.NET MVC. Recently, I try to import a javascript file in a asp file. But I get this Error:

Not allowed to load local resource

no matter using IE, Chrome or Firefox.

My code:

*/Views/Menu.aspx*

  <head runat="server">
  <title>...</title>
  <script language="javascript" type="text/javascript" src="file:///C:/Users/...(Absolute Path).../jquery.min.js"></script>
   </head>

I study other similar questions and I think maybe this is a secure problem. But I still don't know how to solve it.

Could anyone give me come give me some advice?

Liam
  • 27,717
  • 28
  • 128
  • 190
wind910037
  • 21
  • 5

1 Answers1

0

The way you are adding your javascript file is wrong:

<script language="javascript" type="text/javascript" src="file:///C:/Users/...(Absolute Path).../jquery.min.js"></script>

Just add the required js file in your MVC solution in a folder e.g scripts folder and then drag and drop the file in src of script tag like below :

<script type="text/javascript" language="javascript"  src="scripts/jquery-1.8.3.js"></script>
jANVI
  • 718
  • 3
  • 12
  • I have already tried this method,but the broswer will failed to load resource. – wind910037 Sep 20 '17 at 09:56
  • it will be easy to identify the issue of you can share some screenshots indicating issue – jANVI Sep 20 '17 at 09:57
  • I think maybe the problem is the broswer always open the path *http://localhost/scripts/jquery.min.js*. It is not strange that cannot find this path. – wind910037 Sep 20 '17 at 10:08