SaaS CMS has officially launched! Learn more now.

All files return 404 when reading them

Vote:
 

Ahoy.

We've recently upgraded to CMS 12, and now, all our media files are returning 404 to visitors. 

  • When all file paths, blob IDs etc seem correct. They point to the correct files on disk and match records in the database.
  • Uploading new files map them to the correct content type, and puts files correctly on disk where I expect it to. Even thumbnails are generated.
  • All files in question have Read access for Everyone
  • When I open an image in the image editor, the image shows up - so there's obviously ignition somewhere in there.
  • They return 404 both for public URLs and the in-edit-mode-URLs.
  • We have a single FileBlobProvider, pointing to a folder on disk - so nothing very complicated here.

Any pointers?

#311414
Edited, Oct 25, 2023 6:24
Vote:
 

How did you setup the FileBlobProvider?

E.g.

{
    "EPiServer":{
        "Cms":{
            "BlobProvidersOptions": {
                "DefaultProvider": "fileShare",
                "Providers": {
                    "fileShare": "EPiServer.Framework.Blobs.FileBlobProvider, EPiServer.Framework"
                },
            },
            "FileBlobProvider": {
                "Path": "\\\\myserver\\optidata"
            }
        }
    }
}

Have you ensured you have enabled the serving of static files

app.UseStaticFiles();
#311415
Oct 25, 2023 7:21
Vote:
 

The blob provider is added with services.AddFileBlobProvider("fileShare", configuration.EpiserverBlobPath); where the configured blob path indeed exists. Obviously is picked up, since uploads put new files in the correct place (Updated original post with this now.)

UseStaticFiles() is also called. May it be the order in which this is placed? If so, where should it be, set up against all the other must-haves?

#311418
Oct 25, 2023 7:26
Vote:
 

I noticed something now:

Part of our config is this:

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapEPiServerExtensionEndpoints();
});

If I replace the MapEPiServerExtensionEndpoints() with MapContent(), the images work, but it shuts down our own controllers (with System.ArgumentNullException: Value cannot be null. (Parameter 'key')).

This whole code base is not using any razor pages; it's purely a content API with custom controllers (with route attributes), so we don't need any default routing or anything from the CMS, except for media files. Are there other alternatives here that would help? A lot of the stuff inside MapContent() is internal, so I can't add it myself...

#311422
Edited, Oct 25, 2023 10:38
Vote:
 

Which version of CMS12 are you running?

Are you using minimal api:s or regular web api:s?

I typically add specific endpoints registrations for API:s in CMS12.

public static class ServiceCollectionExtensions
{
	internal const string ApiRoute = "/api/myapi";

	public static IEndpointRouteBuilder MyApiEndpoint(this IEndpointRouteBuilder builder)
	{
		builder.MapGet(ApiRoute, (MyApiRequest request, IMyApiService service) =>
		{
			var response = service.GetMyStuff(request.whaterver, request.somethingelse);
			return Microsoft.AspNetCore.Http.Results.Json(response, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = null });
		});

		return builder;
	}
}

// in startup
app.UseEndpoints(endpoints =>
{
    endpoints.MyApiEndpoint();
    endpoints.MapContent();
    // ...
});
#311424
Oct 25, 2023 10:59
Vote:
 

Version: 12.19.0 - so pretty much up to date.

Regular oldschool Controllers with [Route("...")] scattered around. It's not an option to rewrite this into flat MapGet(...) as you showed here... :-\ 

It seems very strange to me though, that such a standard thing is so....obscure? Having some pure API-controllers on the side of page controllers must be something every project has, no?

#311425
Edited, Oct 25, 2023 11:06
Vote:
 

Seems like the issue was some custom template resolution on our side, that basically selects an empty object. So, if fiddling about with the ITemplateResolver.TemplateResolving event, beware.

In addition, a basic, empty content controller was required too. If not, everything just returns empty responses. For some reason. 🤷

public class RootContentController : ContentController<PageData>
{
public ActionResult Index(PageData currentPage)
{
return Content("Hello world!");
}
}
#311427
Edited, Oct 25, 2023 11:34
Vote:
 

Wow, that's a tough guess

#311428
Oct 25, 2023 11:56
Arve Systad - Oct 25, 2023 12:06
Indeed. Dark magic happens below the surface...
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.