Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

My colleague just reported that he developed a master page with embedded JScript using Windows Server 2003. The same master page fails to execute the JScript when used on a Windows Server 2008 front-end. Has anyone faced a similar issue? Any information on the root cause?

share|improve this question

1 Answer 1

Is the JScript running server or client-side? If server-side, SharePoint's safe mode parser will block the request. This is SharePoint's protection mechanism to deal with the fact that end users can add content to SharePoint pages. If client-side, it could be the same issue, I'm not 100% sure.

Assuming it is indeed the safe mode parser which is preventing your script executing, you have two options, one recommended, one defintely not:

Not recommended:

Edit the PageParserPath declaration in web.config to allow in-line script:

VirtualPath="/myPathHere/*"
IncludeSubFolders="true"
CompilationMode="Always"
AllowServerSideScript="true" />

Recommended:

Create a control (user control, server control, whatever) to output your script. Ensure a SafeControls entry is added to the application's web.config for this assembly/namespace/class - you are effectively telling SharePoint this code is safe to run by doing this.

The first option is not recommended as it's likely you will open security holes by doing this e.g. some code could be added to a page somewhere else (where you weren't expecting it)which is being allowed to run because you've disabled the safe mode parser. Very dangerous.

share|improve this answer
    
Thanks, we'll check the safe mode parsing option, although it is not likely to influence this. The script should be running on the client side. I still need to check whether it gets to the browser at all... –  Alexey Krasheninnikov Jan 11 '10 at 13:55
    
And yes, I already recommended him to use Jan Tielens's SmartTools approach (Delegate Control to AdditionalPageHead content placeholder). –  Alexey Krasheninnikov Jan 11 '10 at 13:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.