I have some javascript files that are named starting with an underscore. When I publish these it seems they can't be found. Is there some rule that stops these being viewed by the browser when running on IIS? I think I remember something like that for the cshtml files but didn't know that applies to js files.
-
Are they actually published and exists on the server?Artem Koshelev– Artem Koshelev2011-11-09 05:51:04 +00:00Commented Nov 9, 2011 at 5:51
-
Can't say right now as I am having problems getting a remote connection to the server. However other files publish okay. These js are used within MVC areas. I am wondering if that is the problem.Samantha J T Star– Samantha J T Star2011-11-09 06:11:27 +00:00Commented Nov 9, 2011 at 6:11
-
Yes the javascript files are on the server. When I am on the server and click on that javascript within IIS it opens the browser and says cannot be found. Click on js outside of the area and no problem it opens up.Samantha J T Star– Samantha J T Star2011-11-09 08:25:19 +00:00Commented Nov 9, 2011 at 8:25
-
“These js are used within MVC areas” — Are they stored in Views folder?Artem Koshelev– Artem Koshelev2011-11-09 08:49:35 +00:00Commented Nov 9, 2011 at 8:49
2 Answers
I found the following post, which talks about files with "_" prefix: Why does Razor _layout.cshtml have a leading underscore in file name?.
By convention, the Razor pages that cannot be shown by the browser via direct request are prefixed with "_". Following is one of the comments from the post:
Razor was developed for ASP.NET Web Pages (WebMatrix), which doesn't have the same sort of protection built in regarding Views folders and Routing that you get within MVC. Since layout pages in Web Pages are not intended to be served directly, they are prefixed with the underscore. And the Web Pages framework has been configured not to allow files with leading underscores in their names from being requested directly.
1 Comment
In your View is the reference to them pointed to the correct path?
<script src="@Url.Content("~/Scripts/jquery-custom.js")" type="text/javascript"></script>
I would also hit Control + F5 several times after the page loads to make sure it is not cached and that is the reason it is not pulling down.