Jquery does not work in asp.net mvc after publishing to server

I created an mvc application that contains some jquery code. When I run the application from my ide, everything works fine. When I publish on the server and open the page, jquery does not work. I get the expected errors of the object.

Could this be due to my file associations? here is an example of my mapping in the application -

<script type="text/javascript" href="../../Scripts/jquery-1.3.2.js"></script>  

I have successfully published an application for iis7, but jquery is not working. I published the application on an existing website.

Any thoughts?

+3
source share
1 answer

You may have problems with your relative path.

You can try this, this is the path from the root of the application:

<script type="text/javascript" href="/Scripts/jquery-1.3.2.js"></script>  

Or is this a C # solution:

<script src="<%= Url.Content("~/Scripts/jquery-1.3.2.js") %>" type="text/javascript"></script>
+10
source

Source: https://habr.com/ru/post/1741941/


All Articles