IIS部署JQuery Web应用遇404错误及页面显示异常求助
Hey there! Let’s work through this deployment problem together—it’s super common when moving from a local dev server like http-server to IIS, and the root cause almost always boils down to static asset serving or configuration mismatches. Here’s a step-by-step breakdown to fix those 404 JS errors, broken menus, and partial text display:
1. Double-Check Site Path & Resource References
- First, confirm your IIS site’s physical path points directly to your app’s folder under wwwroot. For example, if you copied code to
C:\inetpub\wwwroot\MyWebApplication, the site’s physical path must be set to that exact folder—not justC:\inetpub\wwwroot. - Open your browser’s DevTools (F12) → Network tab, look at the failed JS requests. Compare the requested URL (e.g.,
http://localhost/js/app.js) to where the file actually lives on the server (e.g.,C:\inetpub\wwwroot\MyWebApplication\js\app.js). If there’s a mismatch (like missing/MyWebApplicationin the request), your HTML’s resource paths are off. Fix them to use relative paths (e.g.,./js/app.js) instead of absolute paths if needed.
2. Enable Static Content in IIS
IIS doesn’t serve static files like JS/CSS by default—this is a top culprit for 404s:
- Open Server Manager → Add Roles and Features.
- Navigate to Web Server (IIS) → Web Server → Common HTTP Features.
- Check the box for Static Content, then complete the installation.
- Restart your IIS site (right-click the site → Manage Website → Restart).
3. Adjust Application Pool Settings
Since this is a pure front-end jQuery app, you don’t need .NET runtime support:
- Go to IIS Manager → Application Pools.
- Find the pool linked to your
MyWebApplicationsite, right-click it → Advanced Settings. - Under General, set .NET CLR Version to
No Managed Code. - Save the changes and restart the application pool.
4. Verify Folder Permissions
IIS needs read access to your app’s files:
- Right-click your
MyWebApplicationfolder → Properties → Security tab. - Click Edit → Add, then type
IIS_IUSRSin the object name field and click Check Names to confirm. - Give this user Read and List Folder Contents permissions, then apply the changes.
5. Test Direct Static Asset Access
To isolate the issue, try accessing a JS file directly via URL (e.g., http://localhost/MyWebApplication/js/jquery.min.js):
- If you get a 404: Double-check the file exists in the correct path and your site’s physical path is set right.
- If you get a 403: Permissions are the problem—go back to step 4 to fix them.
Once you work through these steps, your app should load correctly, menus should function, and those JS 404 errors should disappear. Let me know if you hit any snags along the way!
内容的提问来源于stack exchange,提问作者Pizzor2000

