Potential inconsistency in 404 content returned for missing file depending on mime type

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
If you request a url for a /picture1.jpg image that is not available you get a 404 status returned with no content:




If you request a url for a /picture1.aaa image that is not available you get a 404 status returned with nopcommerce 'Page Not Found' content:




Is this expected behaviour?  Personally, I would expect the 404 to be returned with nopcommerce 'Page Not Found' content in both cases.


This happens because of the setup in ApplicationBuilderExtensions.UsePageNotFound():

    public static void UsePageNotFound(this IApplicationBuilder application)
    {
        application.UseStatusCodePages(async context =>
        {
            //handle 404 Not Found
            if (context.HttpContext.Response.StatusCode == StatusCodes.Status404NotFound)
            {
                var webHelper = EngineContext.Current.Resolve<IWebHelper>();
                if (!webHelper.IsStaticResource())
                {
                    ...

                    //get new path
                    context.HttpContext.Request.Path = "/page-not-found";



The webHelper.IsStaticResource() determines if the resource is static by calling FileExtensionContentTypeProvider.TryGetContentType(String, String) to determine if the MIME type is recognised.

Do we need this check?  We know that we already have a 404 from the inital status code check so why not skip the MIME type check and display the Page Not Found content in all cases?
5 years ago
I've just noticed that there is a 'Suggestions and Feedback' board.  Would this type of suggestion be better suited for that group rather than the 'Development' board?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.