Question

Custom K2 control - JavaScript file refusing to load because of mime type

  • 2 April 2023
  • 2 replies
  • 1092 views

Userlevel 3
Badge +9

Hi there,

I have a custom control that I have been making changes to and it is working as expected on the server I have developed it on.

When I go to deploy the newer version to a different K2 server (the older version was deployed and working as expected on the 3 other servers) I am getting the following when the Forms engine is trying to read the .js file associated with the control (this happens for both the designer and runtime sites):

Refused to execute script from 'https://my_k2_server/Designer/Bundles/Js/DT.K2.Forms.Custom.My_Custom_Control?_v=5.1012.21313.1' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

If I load through chrome developer tools on the server that I developed the control on the above equivalent Url, the server returns the JavaScript file contents as expected to the browser.

There were a number of xml property changes so I had to re-run the controlutil.exe to update it (this normally isn’t a problem but am mentioning it just in case).

The .js file in the Visual Studio project has as far as I can tell not changed project-wise (it is still an embedded resource) and is referred to correctly in the code behind file and I can’t see anywhere that I could have specifically modified the file to be of type text/html.

The .js file is parsing as valid JavaScript, as is the XML definition file.

Things I have tried:

  1. Clearing the control cache on working and destination servers (https://my_k2_server/designer/Caching/CacheControl.ashx?m=CLEAR)
  2. Restarting IIS on the destination server
  3. Rebooting the destination server
  4. Deregistering the control and reinstalling it fresh on the destination server

If I redeploy the previous version of the DLL to the destination server then that version works as expected.

Does anyone have any ideas as to why I am getting this problem and how to solve it?

Full disclosure - the development server is 5.6 and the target servers are 5.4 (but this hasn’t been an issue when developing custom controls in the past on the exact same set-up)

Cheers


2 replies

Userlevel 3
Badge +9

After much MUCH debugging it appears as though the problem is related to me having UseMinifiedFiles=”true” in the web.config files for the designer and runtime websites for the servers that I am not developing on.

The 5.6 server doesn’t suffer from this problem with UseMinifiedFiles=”true” but the 5.4 boxes do.

Userlevel 3
Badge +10

@paulk

There is also a ‘Content’ folder in both the Designer Runtime and Runtime Runtime folder (for example ‘C:\Program Files\K2\K2 smartforms Runtime\Content’) that caches resources on IIS start up.  You can try:

  • setting UseMinifiedFiles=”true” back to true
  • creating a folder in the Content folder, and moving all items in the Content folder into this folder; or deleting the items in the content folder
  • Perform an IISRESET

On IIS startup, you should see it start to cache files in this folder again.  Retest.

Reply