I'm using custom page layout for storing publishing pages.In that i had used ajax function: I had followed below links but no success:


Code blocks not allowed searchresults.aspx

         type: "POST",
         url: "<%#WebConfigurationManager.AppSettings["PortalUrl"]%>/_layouts/15/Module/Ajax.aspx/GetScreen",
         data: JSON.stringify({ typeId: categoryId }),
         contentType: "application/json; charset=utf-8",
         success: function (data) {
         if (data.d != "") {
                 var imageUrl = data.d;
                 $(".listdetailbanner").css({ "background": "url(" + imageUrl + ") 
                 no-repeat center", "margin-bottom": "20px", "background-size": "cover" });
           error: function () {

enter image description here

  • Allowing code blocks is a procedure to allow server-side code. Here you show us only JavaScript, i.e. client-side code... Do you have server-side code elsewhere in the file? Also: did you add the layout file or the final publishing page URL in the web.config file to allow it to execute code blocks? – Evariste Jul 21 '15 at 10:44
  • i'm using this line in ajax url: "<%#WebConfigurationManager.AppSettings["PortalUrl"]%>" becoz of this i'm getting error i think. – Light Jul 21 '15 at 10:47
  • OK, I had missed it, sorry! That's indeed the "unsafe" server-side code, OK :) Now, what URL did you put in the web.config? The publishing page URL or the layout URL? – Evariste Jul 21 '15 at 10:49
  • site collection url "comp-pcname:11111" – Light Jul 21 '15 at 10:51
  • With a star * like this VirtualPath="/*"? – Evariste Jul 21 '15 at 10:52

Can you try with:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="250" AllowPageLevelTrace="false"> 
  <PageParserPath VirtualPath="~/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" /> 


<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="250" AllowPageLevelTrace="false"> 
  <PageParserPath VirtualPath="~/*" CompilationMode="Always" AllowServerSideScript="true" /> 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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