Hello all,
I have installed content delivery api packages from package manager console
i.e. Install-Package EPiServer.ContentDeliveryApi
steps given in the link https://world.episerver.com/documentation/developer-guides/content-delivery-api/getting-started/
below are package details
<package id="EPiServer.ContentDeliveryApi" version="2.13.0" targetFramework="net472" />
<package id="EPiServer.ContentDeliveryApi.Cms" version="2.13.0" targetFramework="net472" />
<package id="EPiServer.ContentDeliveryApi.Core" version="2.13.0" targetFramework="net472" />
<package id="EPiServer.ContentDeliveryApi.OAuth" version="2.6.0" targetFramework="net472" />
<package id="EPiServer.ContentDeliveryApi.Search" version="2.13.0" targetFramework="net472" />
Created a Initialization Module
[InitializableModule]
[ModuleDependency(typeof(ServiceContainerInitialization), typeof(ContentApiCmsInitialization))]
public class ContentApiInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.AddTransient<RoutingEventHandler, CustomContentApiRoutingEventHandler>();
context.Services.AddTransient<ContentApiRouteService, CustomContentApiRouteService>();
// set minimumRoles to empty to allow anonymous calls (for visitors to view site in view mode)
context.Services.Configure<ContentApiConfiguration>(config =>
{
config.Default()
.SetMinimumRoles(string.Empty)
.SetSiteDefinitionApiEnabled(true);
});
}
public void Initialize(InitializationEngine context)
{
// Method intentionally left empty.
}
public void Uninitialize(InitializationEngine context)
{
// Method intentionally left empty.
}
}
----
public class CustomContentApiRouteService : EPiServer.ContentApi.Routing.ContentApiRouteService
{
public override bool ShouldRouteRequest(HttpRequestBase request)
{
bool isRoutedByContentApi = false;
if (bool.TryParse(request.Headers["Route-By-ContentApi"], out isRoutedByContentApi))
{
return isRoutedByContentApi;
}
return false;
}
}
------
/// <summary>
/// Custom routing event handler.
/// </summary>
public class CustomContentApiRoutingEventHandler : RoutingEventHandler
{
public CustomContentApiRoutingEventHandler(
IContentRouteEvents routeEvents,
ServiceAccessor<HttpContextBase> httpContextAccessor,
ContentApiRouteService contentApiRouteService)
: base(routeEvents, httpContextAccessor, contentApiRouteService)
{
}
// If language does not exists in the routing context, we return ContentLanguage.PreferredCulture as default language
protected override string GetLanguage(SegmentContext routingContext, HttpRequestBase request)
{
var language = routingContext.Language ?? routingContext.ContentLanguage ?? ContentLanguage.PreferredCulture.Name;
return language;
}
}
------
Evrything is working fine on develpment envrionment.
But on integration environment (DXC) CMS is not working
http://<myqasite>/EPiServer/CMS/?language=en
Page could not be loaded
The link you specified does not work. This may either be the result of temporary maintenance or an incorrect link.
I have checked the logs.
Logs as below
EPiServer.Global : Unhandled exception in ASP.NET
System.ArgumentException: Value cannot be null or empty.
Parameter name: controllerName
at System.Web.Mvc.HandleErrorInfo..ctor(Exception exception, String controllerName, String actionName)
at System.Web.Mvc.HandleErrorAttribute.OnException(ExceptionContext filterContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at EPiServer.Shell.Services.Rest.RestControllerBase.EndExecute(IAsyncResult asyncResult)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I am not sure why I am facing this issue on cloud envrionment only.