November Happy Hour will be moved to Thursday December 5th.

Setting up DDS

Vote:
 

I was wondering if someone came across this scenario after upgrading to CMS 12

We have a Cart class and an API controller that should return Cart object. 

Method is defined as such:

[HttpGet]
[Produces(typeof(Cart))]
public Cart Get()
{
    return CartService.GetCart(IdentityService.GetUserId());
}

In the appSettings.json there is this part

 "DynamicDataStore": {
      "AutoResolveTypes": "true",
      "AutoRemapStores": "true"
 }

Get method produces nice Cart object but instead of returning it as such process gets redirected to StartPage or '/'. Could it be due wrong binding or mapping?

#302981
Edited, Jun 05, 2023 11:49
Vote:
 

What is CartService here? If it's not built using DDS (Dynamic Data Store), then the DDS settings doesn't matter. However, those settings doesn't matter here anyway, there's something else in your code base that causes the redirect. 

#303052
Edited, Jun 06, 2023 18:23
Vote:
 

Hi Johan,

the issue was that the cart was null when visitors came to the site for the first time. It seems that in that case default response is 204 content not found instead of null object.

In our case the solution was to put this into Startup class

 services.AddControllers(options =>
 {
      options.OutputFormatters.RemoveType<HttpNoContentOutputFormatter>();
 });
#303093
Jun 07, 2023 7:14
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.