Question

I want to reference a javascript file at the bottom of a page template.

I added the .js file under cmssitemanager / development / javascript files and then added the following to the master template (portal engine):

<script src="/CMSScripts/Custom/FOO/BAR.js"></script>

When I open the page in any browser, the javascript in the file isn't executing.

When try to access the file directly in the browser at domain.com/CMSScripts/Custom/FOO/BAR.js I get redirected to the Kentico logon page.

I don't see how/where I can specify security for the CMSScripts directory, but the user should not have to be logged in to access this file.

Any suggestions?

Update with info from first answer:

  1. We are not currently using Windows Authentication, and I verified that the application pool user account has file-system permissions. I also verified that the application can add/delete/modify files using the cmssitemanager > administration > system > files > "test files" utility which resulted in OK status for creating/deleting/modifying folders and files.

  2. I do have Check files permission checked in cmssitemanager > settings > system > files > security. Unchecking this option does not change the behavior, including after restarting both the application and the windows services.

  3. The site is valid and has the correct license however there was NOT a domain alias defined. I added one however this did not change the behavior.

  4. We have not made any changes to the web.config save for connection string information. If you are referring to this documentation on CMSUseTrailingSlashOnlyForExtensionLess in the web.config, this was not previously in there however adding it did not change anything. To that end, I wasn't seeing the site trying to redirect to domain.com/CMSScripts/Custom/FOO/BAR.js/ so I truly think it's tied to some kind of security ACL that is out of order.

Was it helpful?

Solution

Here is the solution provided by user FroggEye on the Kentico DevNet forum thread on this same issue:

You're best bet is to use the syntax below. Kentico does URL processing on all directories unless excluded and you'd have to exclude the CMSScripts directory from processing which isn't hard but the code below is a better solution.

<script src="/CMSPages/GetResource.ashx?scriptfile=/CMSScripts/Custom/FOO/BAR.js" type="text/javascript"></script>

This will do 2 things:

  1. give you a standard place to call resources from (you can get stylesheets here as well)
  2. allow you to use the build-in minimization functions.

OTHER TIPS

Charles,

This is a strange behavior, it does not normally do that.

  1. Do you have any windows auth going on ? where you possibly removed anonymous access (in IIS) to directories in the website folder ?

  2. Do you have Check Files permissions turned on as a Kentico Site setting? (even though I'm fairly sure that won't affect requests to the JavaScript files in JS module)

  3. Is it a valid site (enabled and running in CMSSiteManager) and domain name with a correct license and alias ?

  4. Any custom modifications to web.config file that possibly changed httpHandlers or modules ? And are you running the correct extensionless URL settings in web.config ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top