Skip to content

The admin controller save action can redirect wrong depending on site routing setup #10

Description

@eriktacknoaignite

If the site where the plugin is installed have some catch-all routing configured, for example like so:

app.UseEndpoints(endpoints => {
   endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}");
...
}

The return RedirectToAction("Index"); response when saving admin settings will 404 as the default route will catch it and generate /SiteimproveAdmin/Index as URL.

As the siteimprove plugin should not dictate how routing can or cannot be configured on the site, my suggestion is to instead resolve the same URL as is already done on line 50 of the same class and use that as redirect URL:

PluginUrl = _moduleResourceResolver.ResolvePath(Constants.SiteImproveModuleName, "SiteimproveAdmin"),

So something like this:

var url = _moduleResourceResolver.ResolvePath(Constants.SiteImproveModuleName, "SiteimproveAdmin");
return Redirect(url);
// or with query in EnablePrepublishCheck:
return Redirect(url + "?prepublishError=true");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions