1

We have created a solution based on template sitecore.aspnet.gettingstarted for Sitecore ASP Net Core Rendering SDK headless.

Pushed all the Sitecore items available in this solution successfully and hosted RenderingHost application as well on IIS.

I am able to browse the home page when I hit the RenderingHost website on browser but when I try to open the same item in the Experience Editor getting following issue:

Error Rendering Sitecore.JavaScriptServices.ViewEngine.Presentation.JsLayoutRenderer: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Sitecore.JavaScriptServices.ViewEngine.Http.RenderEngine.Invoke[T](String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.PerformRender(TextWriter writer, IRenderEngine renderEngine, String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.Render(TextWriter writer)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)

Using Sitecore 10.1 on-prem over IIS (no docker)

When I try to debug the code, i don't see any error on the code.

Following is the appsettings.json file at RenderingHost application:

{
  "Sitecore": {
    "InstanceUri": "https://sc101sc.dev.local",
    "LayoutServicePath": "/sitecore/api/layout/render/jss",
    "DefaultSiteName": "AspCoreHeadless",
    "ApiKey": "d807e76d-3151-41a9-8e1a-ffede8851926",
    "EnableExperienceEditor": true
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

Can someone help in resolving this issue?

Thanks,

4
  • Just a guess, could be not receiving JSON back and possibly getting some kind of error formatted as HTML. Feb 20, 2022 at 13:31
  • Thanks @MichaelWest for your response. I put the debugger at .cshtml view and did not find any issue. Even getting json response from layoutservice.
    – Jitendra
    Feb 20, 2022 at 14:18
  • @Jitendra did you manage to find a solution?
    – grg
    Aug 30, 2022 at 14:18
  • Add solution - @grg
    – Jitendra
    Aug 31, 2022 at 9:04

1 Answer 1

1

In my case, configuration at the CM website was wrong.

<?xml version="1.0"?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
    <sites>
      <!--
        Configure the site definition for our Getting Started site.
      -->
      <site name="AspCoreHeadless"
            inherits="website"
            hostName="sc101sc.dev.local"
            rootPath="/sitecore/content/AspCoreHeadless"
            patch:before="site[@name='website']" />
    </sites>
    <javaScriptServices>
      <apps>
        <!--
          We need to configure an 'app' for the site as well in order to
          enable support for Experience Editor. The URL below will be used
          by the Experience Editor to render pages for editing.
        -->
        <app name="AspCoreHeadless"
             sitecorePath="/sitecore/content/AspCoreHeadless"
             serverSideRenderingEngine="http"
             serverSideRenderingEngineEndpointUrl="http://aspcoreheadless/jss-render"
             serverSideRenderingEngineApplicationUrl="https://sc101sc.dev.local"
             inherits="defaults" />
        
      </apps>
    </javaScriptServices>
  </sitecore>
</configuration>

After this change, I am able to see the website on the experience editor. Even I can change the content in the experience editor as well.

Hope this will help to others.

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.