404 Handling in V4.0?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi all,

I have migrated an old aspx site to V4.0 of nopcommerce and would like to make sure that the depricated pages, rather than show the Page not found, go to the home page. What is the best way to do this?

Thanks,
Jon
5 years ago
If you have a list of old urls, you can use web.config for setting up redirection rules.

Hope that helps.
Regards,
Anshul
5 years ago
RoastedBytes wrote:
If you have a list of old urls, you can use web.config for setting up redirection rules.

Hope that helps.
Regards,
Anshul


The sheer number of old URLs makes this very impractical. Is there any other way?
5 years ago
Probably, You need to modify the startup.cs as following way.


public void Configure(IApplicationBuilder application)
        {

            application.Use(async (context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404)
                {
                    context.Request.Path = "/Home";
                    await next();
                }
            });
           application.ConfigureRequestPipeline();
        }




or you can add new method in the \Nop.Web.Framework\Infrastructure\Extensions\ApplicationBuilderExtensions for the same.

Please check and update your review here.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.