I have the following in my Razor view for an editor template in my Orchard module:
Script.Include("assets.js").AtFoot();
When the page is rendered I can see this line at the bottom:
<script src="/Modules/MyModuleName/scripts/assets.js" type="text/javascript"></script>
Beautiful! Only problem is, when I visit that path I get a 404 error. The script doesn't exist.
...but it does! It's saved as Orchard.Web\Modules\MyModuleName\Scripts\assets.js
The rest of my module's functionality works fine - I can enable and use it, it just won't find the script file. Am I missing something obvious here?!
I found an other reason for this 404 which I would like to mention. UrlScan by default rejects a dot in the path, I found this in my log: Rejected URL+contains+dot+in+path
So change the setting in:
and it works again. It took me some time to find this, because I never use a dot in path...
By default, Orchard is setup to restrict folder permissions. This is usually overriden by adding a web.config to each folder as required (in this case, your scripts folder).
If you use the codegen module to generate your module, then this is done for you as part of the generation. If not, then you need to add the web.config yourself.
The codegenned web.config looks like this: