model view controller – Referencing script files from MVC – Education Career Blog

I am having problems referencing scripts that should be included in my view, when I access the page using a different route my scripts fail.

The idea is that two routes actually point to the same action:

http://localhost/PaydayWebsite/registration

http://localhost/PaydayWebsite/organizations/p001/departments/vest/employees/chn/registration

where the second just include more params for my action. I have tried using

ResolveUrl, Url.Content and mvccontribs Html.ScriptInclude but neither seem to work. Any ideas?

,

You should be able to use Url.Content, but you’ll need to make your path relative to the root of the application rather than the current path.

Use

 Url.Content( "~/Content/Scripts/jquery-1.3.2.min.js" )

rather than

 Url.Content( "../../Content/Scripts/jquery-1.3.2.min.js" )

Leave a Comment