Geta / geta-notfoundhandler

The popular NotFound handler for ASP.NET Core and Optimizely, enabling better control over your 404 page in addition to allowing redirects for old URLs that no longer works.
Apache License 2.0
19 stars 16 forks source link

Routing conflict #93

Closed Dandroid5000 closed 1 year ago

Dandroid5000 commented 1 year ago

We have recently updated Optimizely packages EPiServer.CMS.Core 12.9.2 to 12.14.0 and are now getting a route conflict between our start page path ("/") and the path to add/delete a redirect "getanotfoundhandleradmin/?handler=create".

Currently we are unable to add or delete a redirect because the request is returning a 405.

Could you please rename following files to something more targeted? Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Index.cshtml Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Index.cshtml.cs

We were able to resolve this in our testing with the following changes

image

Thanks in advance

Dandroid5000 commented 1 year ago

Hi, has anyone had a chance to look at this? Thanks in advance

Dandroid5000 commented 1 year ago

Can anyone please help with this? Note, we have just been alerted that the same issue is present in the GETA Optimizely Sitemaps package.

marisks commented 1 year ago

@Dandroid5000 What areas/routing configuration do you have? Has it been changed after upgrading from EPiServer.CMS.Core 12.9.2 to 12.14.0?

We use default ASP.NET routing and if it worked before, it should work now too unless there were changes in your project or in EPiServer.CMS.Core. Renaming the file is a workaround and not a proper fix.

svenrog commented 1 year ago

@Dandroid5000 In what way does the above fix your problem with routing? Could it be that your project registers a custom IViewLocationExpander that picks up the start page view instead of respecting the GetaNotFoundHandlerAdmin area somehow?

svenrog commented 1 year ago

I tried reproducing this using Optimizely 12.9.0 and 12.14.0, single and multi-site configuration. Everything seemed to work correctly.

Dandroid5000 commented 1 year ago

Hi @marisks , thanks so much for getting back to me. We are using attribute-based routing. This is a multi-site setup wherein each site is defined within an MVC area. Each page controller within each area uses a base controller that specifies the route and the area (see below). image

Nothing has changed with respect to routing in our project since upgrading from EPiServer.CMS.Core 12.9.2 to 12.14.0, nothing that myself or my teammates have been able to determine anyway.

Dandroid5000 commented 1 year ago

@svenrog The only configuration change we have for custom View Locations is per below image

Dandroid5000 commented 1 year ago

https://github.com/Geta/geta-notfoundhandler/blob/ca1f3730af6cdbdd797cc2c0d541143216e1acc5/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Shared/_Layout.cshtml#L45C32-L45C32

^ this link is resolving to our HomepageController and hitting its Index.cshtml... this was not happening before.

Dandroid5000 commented 1 year ago

I found another workaround following this: https://stackoverflow.com/questions/50815280/razor-pages-form-page-handler-not-working-with-get-method ^ i.e. adding the route ("{handler?}") to the @page declaration in \Geta.NotFoundHandler.Admin\Areas\GetaNotFoundHandlerAdmin\Pages\Index.cshtml image

^ this also fixes the issue in our testing so far

svenrog commented 1 year ago

@Dandroid5000 Does adding asp-area="GetaNotFoundHandlerAdmin" to the taghelpers with links work too?

Dandroid5000 commented 1 year ago

Hi @svenrog. Yes! That seems to work too :D

Dandroid5000 commented 1 year ago

Hi @svenrog , hi @marisks

Thanks so much for the code fix! I look forward to testing it out when it hits the nuget feed!

Regarding the same issue in your sitemaps plugin (https://github.com/Geta/geta-optimizely-sitemaps), would you like me to raise an issue over on that repo too?

valdisiljuconoks commented 1 year ago

Yes, please do register there as well (it will help us to keep track of issues resolved in next version).

Thx!

marisks commented 1 year ago

The new package is published.