asawyer
asawyer

Reputation: 17808

mvc script / content items 404 on page load

When I run my mvc 2 application locally everything works fine, and the request log looks like this:

GET /Scripts/jquery-1.4.1.min.js HTTP/1.1
Accept: */*
Referer: http://localhost.:2846/
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Connection: Keep-Alive
Host: localhost.:2846

After moving the project to a remote test server all of the css and javascript files are coming back as 404

GET /Scripts/jquery-1.4.1.min.js HTTP/1.1
Accept: */*
Referer: http://vnt2k3qa3/NewEmployee
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Connection: Keep-Alive
Host: vnt2k3qa3

Response

HTTP/1.1 404 Not Found
Content-Length: 1635
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Wed, 23 Feb 2011 23:18:32 GMT

Anyone happen to know what is going on here?

The site is setup for anon access, and I can manually enter the url for a script or css file and it pulls down just fine!

Edit

The script references in question are in the head section of the master page at

/Views/Shared/Site.Master

<head>
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link rel="Stylesheet" href="/Content/Site.css" type="text/css" />
    <script src="/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.color.js" type="text/javascript"></script>
</head>

The views throwing the 404's for these are at

/Views/Home/Index

/Views/NewEmployee/Create

(Basically all I have at this point)

And the content/script folders are at

/Content/Site.css

/Scripts/jquery-1.4.1.min.js

Upvotes: 0

Views: 2556

Answers (1)

nickmoriarty
nickmoriarty

Reputation: 1263

The only thing I can see might be the issue from this is that it looks like it might be looking under the NewEmployee directory for the Scripts folder and I'm guessing that the Scripts folder is under the root. Check out the src attribute you specified for that javascript file to see where it is looking for the file.

I have been using

src='<% = Url.Content("~/Scripts/jquery-1.4.1.js") %>'

for my src tags to make sure they go to the right place no matter where they are used and it works for me.

Upvotes: 2

Related Questions