0

The problem here is that some views (not all of them) can't access to some css&js files(not all of them) ("404 Not found" error).
For exemple View of .../Details/Index/1 can't access to 1file css and 1file js (it can access all other files), but the View of .../Recherche/result can access to all files.
This problem happens when the user is connected and when not connected.
I didn't modifie the web.config file.
All View are related to one Layout, in there I inluded the css files:

<link href="Content/file.css" media="all" rel="stylesheet" type="text/css" />

And one last thing, all css files are in 1 folder and all js files are in 1 folder.

Hodyr
  • 53
  • 7

1 Answers1

3

Start the path to the file with the tilde (~) character. Razor will converts a virtual (relative) path to an application absolute path.

<link href="~/Content/file.css" media="all" rel="stylesheet" type="text/css" />

If you are using an MVC version prior to MVC 4, you should use Url.Content helper method.

<link href="@Url.Content("~/Content/file.css")"  rel="stylesheet" type="text/css" />
Shyju
  • 214,206
  • 104
  • 411
  • 497
  • Correct! Also i strongly advice to use bundling feature of MVC. http://www.asp.net/mvc/overview/performance/bundling-and-minification – c0demaster Nov 30 '15 at 04:19