petrsvihlik / WopiHost

ASP.NET Core MVC implementation of the WOPI protocol. Enables integration with WOPI clients such as Office Online Server.
Other
196 stars 72 forks source link

"camelCase" formatting seems to cause problems with "Office for the web" as client #123

Closed planax closed 3 years ago

planax commented 3 years ago

https://github.com/petrsvihlik/WopiHost/blob/842e6ff132716afc087a16f1e215ec74c93fae46/WopiHost.Core/Controllers/FilesController.cs#L78

For me, when using .NET 5/Core 3.1, the response will contain JSON key names formatted in camelCase. This seems to be the new default.

{
  "baseFileName": "TestDocument.docx",
  "ownerId": "uid-12345-6789",
  "size": 1234567,
  "userId": "uid-12345-6789",
  "version": "1234567"
}

This wouldn't be per se a problem, but when using Office for the web as Wopi Client, no GetFile will be sent back. After quite some time reading the MS-WOPI protocol specification, part 3.3.5.1.2.2, I realized that this was the reason.

I fixed the issue by forcing PascalCase, which seems to be what MS-WOPI expects.

Before: https://github.com/petrsvihlik/WopiHost/blob/842e6ff132716afc087a16f1e215ec74c93fae46/WopiHost/Startup.cs#L44

After:

services.AddControllers()
  .AddNewtonsoftJson(options =>
  {
      options.SerializerSettings.ContractResolver = new DefaultContractResolver();
  });

Response:

{
  "BaseFileName": "TestDocument.docx",
  "OwnerId": "uid-12345-6789",
  "Size": 1234567,
  "UserId": "uid-12345-6789",
  "Version": "1234567"
}
petrsvihlik commented 3 years ago

Thank you for reporting this @planax , I'll try to reproduce it next week and let you know!

planax commented 3 years ago

@petrsvihlik, this can be closed. It was actually my fault. I didn't notice you were specifying PascalCase formatting in WopiCoreBuilderExtensions class.