twal
twal

Reputation: 7039

external javascript files not loading when published to my server

My ASP.NET MVC app uses some external javascript and jquery files. Everything works just fine on my dev machine. As soon as I post it to my server none of the .js files even load. I have used Url.Content() as well as an app helper with the same result. They work fine on the dev machine but don't even load on when published to the server. I am really at a wall and have no idea what this could be. Any ideas what I could try next? Thanks

I have tried

<script src="../../Scripts/SiteMaster.js" type="text/javascript"></script>

as well as

<script src='<%=Url.Content("~/Scripts/SiteMaster.js") %>' type="text/javascript"></script>

both work on the dev machine neither work on the server.

Upvotes: 0

Views: 1555

Answers (2)

twal
twal

Reputation: 7039

I found the Issue!!! my other programmer created a virtual directory (for some reason) named "scripts" in IIS and had it pointed at a different location on the file system. I appreciate all your help with this! I have fixed it. Thanks Again!

Upvotes: 0

hunter
hunter

Reputation: 63542

ResolveUrl should be all you need

<script 
    src="<%=ResolveUrl("~/Scripts/SiteMaster.js") %>" 
    type="text/javascript"></script>

also make sure you've added this IgnoreRoute:

routes.IgnoreRoute("scripts/{*pathInfo}");

Upvotes: 3

Related Questions