"Specified method is not supported"

I have…

  • [X ] Checked the logs and have provided the logs if I found something suspicious there

{"StatusCode":500,"Message":"Specified method is not supported.","StackTrace":" at System.Net.Http.HttpBaseStream.get_Length()\r\n at System.Text.Json.JsonPropertyInfoNotNullable4.OnWrite(WriteStackFrame& current, Utf8JsonWriter writer)\r\n at System.Text.Json.JsonPropertyInfo.Write(WriteStack& state, Utf8JsonWriter writer)\r\n at System.Text.Json.JsonSerializer.Write(Utf8JsonWriter writer, Int32 originalWriterDepth, Int32 flushThreshold, JsonSerializerOptions options, WriteStack& state)\r\n at System.Text.Json.JsonSerializer.WriteAsyncCore(Stream utf8Json, Object value, Type inputType, JsonSerializerOptions options, CancellationToken cancellationToken)\r\n at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)\r\n at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()\r\n— End of stack trace from previous location where exception was thrown —\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\r\n at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)\r\n at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)\r\n at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)\r\n at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\r\n at AliveCity.App.Middleware.RenderingMiddleware.InvokeAsync(HttpContext context, IPageParsingService pageParsingService, ISiteInfoLookupService siteInfoLookupService, IViewRenderService viewRenderService, ICachingService cachingService) in C:\Users\Blake\Desktop\SeqTek\evetv4\AliveCity.App\Middleware\RenderingMiddleware.cs:line 136\r\n at AliveCity.App.Middleware.SiteLookupMiddleware.InvokeAsync(HttpContext context, ISiteLookupService siteLookupService, ContentService1 headerService, ContentService1 footerService, ContentService1 commonService) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\SiteLookupMiddleware.cs:line 65\r\n at AliveCity.App.Middleware.PageLookupMiddleware.InvokeAsync(HttpContext context, IPageLookupService pageLookupService) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\PageLookupMiddleware.cs:line 55\r\n at AliveCity.App.Middleware.CacheMiddleware.InvokeAsync(HttpContext context, ICachingService cachingService) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\CacheMiddleware.cs:line 55\r\n at AliveCity.App.Middleware.TenantLookupMiddleware.InvokeAsync(HttpContext context, ApplicationDbContext dbContext) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\TenantLookupMiddleware.cs:line 66\r\n at AliveCity.App.Middleware.ModeMiddleware.InvokeAsync(HttpContext context) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\ModeMiddleware.cs:line 43\r\n at AliveCity.App.Middleware.ExceptionMiddleware.Invoke(HttpContext context) in C:\\Users\\Blake\\Desktop\\SeqTek\\evetv4\\AliveCity.App\\Middleware\\ExceptionMiddleware.cs:line 38"}

I’m submitting a…

  • [X ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

When fetching a single asset, I’m getting the above error. The code to fetch it looks like this:
IAssetsClient assetManager = this._clientManager.CreateAssetsClient();
return await assetManager.GetAssetContentAsync(id, 0);

Expected behavior

Return an Asset (FileResponse)

Minimal reproduction of the problem

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ X] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [ X] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Which SDK version do you use? Because this method is actually part of my integration test suite and works fine there: https://github.com/Squidex/squidex/blob/f3f37bfae8cddca43df379089d8f9a1d3a534392/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs#L118

Perhaps your squidex installation is too old? You could try GetAssetContentBySlugAsync

I’ve pulled down the latest Squidex and the latest Client Library, neither fixed the problem and give the same error response.

We cannot switch to GetAssetContentBySlugAsync, as we have components all over the place referencing the ID’s of assets and not slugs.

Are we returning the file response incorrectly? When I used the slug it did find the asset but produced the method not supported error.

Shared with CloudApp

Actually the slug parameter also accepts an id.

You code looks okay. I don’t know yet, where your error is coming from

I had to modify it to return a File and not FileResponse. However, it has it’s content type hardcoded now, is there a way to get that returned from the asset API?

Why are you not creating a redirect instead?

Or can you get the headers from the response?

Can you clarify what you mean by a redirect?

Redirecting requests directly to the API?

Yes, ´right now you a re routing all your traffic through you app, meaning duplicated traffic costs in the worst case. You can just return the link to the original asset.

Got it, did a Redirect() to hit the Asset API directly, seems to be working fine. Thanks for your help.

1 Like