Wednesday, January 22, 2014

MSOCAF error- Remove inline code present in the aspx pages


Remove inline code present in the aspx pages. Inline code is not recommended within a site definition due to the issues involved with the code no longer rendering as soon as the page is customized. Inline code is supportable if included on a page in the _layouts directory. Inline code should not be allowed through the PageParserPath exclusion, except in extremely rare circumstances, because it can be modified without going through any review process. As a result, it represents a danger to the environment’s performance and security. Adding PageParserPath element to the web.config files is not allowed. Modifying these files may ‘break’ SharePoint in some way if you change the wrong part of the file
 
 
Found this error while running the MSOCAF on my project having aspx file been deployed to Layouts folder.
 
This error is mainly due to using the <script> tag in your ascx file as below to refere your "js" files in different location like site assests,layouts or any other location
 
 
<script src="myscripts.js"></script>
 
This tag throws the above error
 
This can be resolved by using the tags as mentioned below
 
<SharePoint:ScriptLink ID="ScriptLink1" Name="~sitecollection/siteassests/myscripts.js" runat="server" />
 
 

2 comments:

  1. I have no script tags in my page, still i get the issue in MSOCAF. How do i fix it?

    ReplyDelete
    Replies
    1. Check your master page. Your master page should be having script tag. If so, replace it with sharepoint script tag.

      Delete