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

404 error / blank edit mode - Dojo class is missing after deployment to Integration (DXP hosting), locally works

Vote:
 

I've implemented an editor descriptor and created dojo class: CustomLinkItemModel.js. Locally everything works, but after deployment to Integration, an edit mode is blank for this block and I've noticed this error in the console: GET https://....com/ClientResources/Scripts/CustomLinkItemModel.js 404. I've also noticed that this js file wasn't be added to relaese package before hosting on DXP.

1) The module.config is located in the root directory (projectName.web) and looks like this:

2) Files structure:


3) The editor descriptor includes a following line:
 ItemModelType = "projectName/CustomLinkItemModel"

4) The CustomLinkItemModel.js looks like this:

Anybody knows what might be wrong or maybe what is missing?

#294437
Edited, Jan 10, 2023 21:38
Vote:
 

This could be caused by case-sensitive URL processing in Linux environment.

Add RouteOptions to Startup.cs:

services.Configure(o => { o.LowercaseUrls = true; });

 

#294478
Jan 11, 2023 0:23
Aneta Petryla - Jan 11, 2023 8:51
It didn't help ;) I've noticed that this file wasn't appended to release package after building in Azure DevOps, maybe structure with ClientResource dictionary is wrong (module.config is included)?
Vote:
 

Any other option why it doesn't exist in the build package (maybe it is the reason of 404 error)? Because locally I have correct structure of ClientResources and the script exists

#294486
Jan 11, 2023 13:27
Vote:
 

@Aneta, in our solution we hold these resources within the wwwroot i.e. 

Our module.config looks like this 

<?xml version="1.0" encoding="utf-8"?>
<module clientResourceRelativePath="2.0" loadFromBin="false">
  <assemblies>
    <!-- The assembly containing the rest store needs to be added. -->
    <add assembly="Redacted.Cms" />
  </assemblies>
  <routes>
    <route url="{moduleArea}/{controller}/{action}/">
      <defaults>
        <add key="moduleArea" value="Redacted.Cms" />
        <add key="controller" value="" />
        <add key="action" value="Index" />
      </defaults>
    </route>
  </routes>
  <dojo>
    <paths>
      <add name="Redacted" path="~/ClientResources/Scripts" />
    </paths>
  </dojo>
  <clientModule initializer="Redacted/ModuleInitializer">
    <moduleDependencies>
      <add dependency="Shell" />
      <add dependency="CMS" type="RunAfter" />
    </moduleDependencies>
  </clientModule>
  <clientResources>
    <!-- Inject our custom Display Option selector -->
    <add name="epi-cms.widgets.base" path="~/ClientResources/Scripts/widget/DisplayOptionSelector.js" resourceType="Script"/>
  </clientResources>
</module>

And in Project file have the following 

  <ItemGroup>
    <Content Update="module.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

Would be worth checking the 3 things over in your solution 

#294489
Edited, Jan 11, 2023 13:37
Aneta Petryla - Jan 11, 2023 13:42
I've just done it: moving it under wwwroot and now I'm waiting for build (probably it should help). Come back with answer :)
Minesh Shah (Netcel) - Jan 11, 2023 13:45
@Aneta Petryla
Ensure you also have the CopyToOutputDirectory set to Always as well in your project file
Aneta Petryla - Jan 11, 2023 15:05
Ok, and what is ModuleInitializer.js, is it needed also to every sojo script run correctly?
Minesh Shah (Netcel) - Jan 11, 2023 15:57
I don't believe you will need this, it was specifically for registering the display option rest store

https://marisks.net/2016/08/08/registering-multiple-dojo-modules/
Aneta Petryla - Jan 11, 2023 21:51
I've needed to restart the app on Integration. Everything is working now! Only moving ClientResources under wwwroot has helped :) Thanks a lot
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.