Good Day All

i have an asp.net 4.5 application. i have hosted it on IIS 7.5 in Windows Server 2008. My application has different folders within it and some are for JS and some are for CSS and etc.. and they are inside a directory named "Shared" in my problem and most of the things especially the css , images etc they are reference like this

 <link href="../Shared/assets/css/bootstrap.css" rel="stylesheet"/> 
 <link rel="apple-touch-icon" sizes="57x57" href="../Shared/assets/ico/apple-touch-icon-57x57.png">

now when i host this Project i have issues with CSS and images because they are not retrieved. i use Fiddler to check what is happening and i realised that after i hosted the application now Fiddler reports a 404 error on the following path

**

there are many of them , this is just an Example. now you can see it it can see the server , but instead of adding my Application or website name , it add the Directory within my application. So basically it should look like this

What could be the Problem.

Thanks

Dani AI

Generated

This is a path-resolution issue rather than a Bootstrap/CSS problem. Fiddler shows the browser requesting files from the server root instead of from the web application's virtual directory, so the server returns 404. As pointed out, purely page-relative links break when pages live at different nesting levels; 's suggestion to centralize shared assets is good, but the link generation must include the application root so the app name appears in the request path.

Server-side resolution of the application root is the safest fix. In Web Forms use ResolveUrl or a server-side link; in MVC (Razor) use Url.Content so the virtual directory is injected into the href at render time. Example patterns:

<!-- Web Forms -->
<link href='<%= ResolveUrl("~/Shared/styles/site.css") %>' rel='stylesheet' />

<!-- MVC / Razor -->
<link href='@Url.Content("~/Shared/styles/site.css")' rel='stylesheet' />

Quick troubleshooting checklist:

  • View the page source (or Fiddler request) to confirm the generated href actually contains the application virtual directory.
  • If the folder is meant to be its own app, convert it to an IIS Application and ensure the app pool uses .NET 4.x.
  • Check IIS static content role, MIME mappings, and request-filtering substatus (IIS logs show 404.* codes with useful substatus).
  • Ensure the site folder grants read access to the IIS user account and that no custom handler/web.config is intercepting static-file extensions.
  • Use a server-side base href with caution: it affects all relative URLs and can break CSS url(...) references.

These steps will ensure links resolve to the correct application path and stop the 404s seen in Fiddler.

Recommended Answers

All 2 Replies

I am not too fimilar with asp.net but with mvc I know that shared assets like this should be in the Content directory.

Sorry if this doesnt help much.

Its a simple path issue for the browser. the "../" is telling the browser to find this file by moving up to the parent directory, then accross to the Shared directory and continue the path listed. This is only going to work at the first level set of folders off the root. Once you get into a second level set of folders, this "../" path isnt going to work.

Another option is to provide the path off of the root. For example, if "shared" folder is a first level folder off the root, you can specificy this path from any page on your site regardless where the page is and the browser will be able to find the target page.

<link href="/Shared/assets/css/bootstrap.css" rel="stylesheet"/> 
 <link rel="apple-touch-icon" sizes="57x57" href="/Shared/assets/ico/apple-touch-icon-57x57.png">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.