Open Closed

Public site/ MVC error handling does not work when CmsKit is enabled #4894


User avatar
0
jfistelmann created

Something from CmsKit is overriding the MVC error handling - resulting in redirects of doom.

  • ABP Framework version: v7.1.1
  • UI type: MVC
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
[15:36:44 INF] Request starting HTTP/2 GET https://localhost:44360/pupsi - -
[15:36:44 INF] Executing endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Route matched with {page = "/Public/CmsKit/Pages/Index", action = "", controller = "", area = ""}. Executing page /Public/CmsKit/Pages/Index
[15:36:44 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
[15:36:44 INF] Executing handler method Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel.OnGetAsync - ModelState is Valid
[15:36:44 WRN] Could not find IdentityClientConfiguration for CmsKitPublic. Either define a configuration for CmsKitPublic or set a default configuration.
[15:36:44 INF] Start processing HTTP request GET https://localhost:44322/api/cms-kit-public/pages/pupsi?api-version=1.0
[15:36:44 INF] Sending HTTP request GET https://localhost:44322/api/cms-kit-public/pages/pupsi?api-version=1.0
[15:36:44 INF] Received HTTP response headers after 18.9676ms - 204
[15:36:44 INF] End processing HTTP request after 19.065ms - 204
[15:36:44 INF] Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.NotFoundResult.
[15:36:44 INF] Executing StatusCodeResult, setting HTTP status code 404
[15:36:44 INF] Executed page /Public/CmsKit/Pages/Index in 19.9671ms
[15:36:44 INF] Executed endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Request finished HTTP/2 GET https://localhost:44360/pupsi - - - 302 - - 21.5203ms
[15:36:44 INF] Request starting HTTP/2 GET https://localhost:44360/Error?httpStatusCode=404 - -
[15:36:44 INF] Executing endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Route matched with {page = "/Public/CmsKit/Pages/Index", action = "", controller = "", area = ""}. Executing page /Public/CmsKit/Pages/Index
[15:36:44 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
[15:36:44 INF] Executing handler method Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel.OnGetAsync - ModelState is Valid
[15:36:44 WRN] Could not find IdentityClientConfiguration for CmsKitPublic. Either define a configuration for CmsKitPublic or set a default configuration.
[15:36:44 INF] Start processing HTTP request GET https://localhost:44322/api/cms-kit-public/pages/Error?api-version=1.0
[15:36:44 INF] Sending HTTP request GET https://localhost:44322/api/cms-kit-public/pages/Error?api-version=1.0
[15:36:44 INF] Received HTTP response headers after 18.3062ms - 204
[15:36:44 INF] End processing HTTP request after 18.401ms - 204
[15:36:44 INF] Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.NotFoundResult.
[15:36:44 INF] Executing StatusCodeResult, setting HTTP status code 404
[15:36:44 INF] Executed page /Public/CmsKit/Pages/Index in 19.2325ms
[15:36:44 INF] Executed endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Request finished HTTP/2 GET https://localhost:44360/Error?httpStatusCode=404 - - - 302 - - 20.6696ms
[15:36:44 INF] Request starting HTTP/2 GET https://localhost:44360/Error?httpStatusCode=404 - -
[15:36:44 INF] Executing endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Route matched with {page = "/Public/CmsKit/Pages/Index", action = "", controller = "", area = ""}. Executing page /Public/CmsKit/Pages/Index
[15:36:44 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
[15:36:44 INF] Executing handler method Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel.OnGetAsync - ModelState is Valid
[15:36:44 WRN] Could not find IdentityClientConfiguration for CmsKitPublic. Either define a configuration for CmsKitPublic or set a default configuration.
[15:36:44 INF] Start processing HTTP request GET https://localhost:44322/api/cms-kit-public/pages/Error?api-version=1.0
[15:36:44 INF] Sending HTTP request GET https://localhost:44322/api/cms-kit-public/pages/Error?api-version=1.0
[15:36:44 INF] Received HTTP response headers after 18.1934ms - 204
[15:36:44 INF] End processing HTTP request after 18.2671ms - 204
[15:36:44 INF] Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.NotFoundResult.
[15:36:44 INF] Executing StatusCodeResult, setting HTTP status code 404
[15:36:44 INF] Executed page /Public/CmsKit/Pages/Index in 18.8792ms
[15:36:44 INF] Executed endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Request finished HTTP/2 GET https://localhost:44360/Error?httpStatusCode=404 - - - 302 - - 20.2102ms
[15:36:44 INF] Request starting HTTP/2 GET https://localhost:44360/Error?httpStatusCode=404 - -
[15:36:44 INF] Executing endpoint '/Public/CmsKit/Pages/Index'
[15:36:44 INF] Route matched with {page = "/Public/CmsKit/Pages/Index", action = "", controller = "", area = ""}. Executing page /Public/CmsKit/Pages/Index
[15:36:44 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
[15:36:44 INF] Executing handler method Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel.OnGetAsync - ModelState is Valid
[15:36:44 WRN] Could not find IdentityClientConfiguration for CmsKitPublic. Either define a configuration for CmsKitPublic or set a default configuration.
[15:36:44 INF] Start processing HTTP request GET https://localhost:44322/api/cms-kit-public/pages/Error?api-version=1.0
And so on... this now repeats.
  • Steps to reproduce the issue:"
  1. Run abp get-source Volo.Abp.LeptonXTheme.Pro
  2. Do the usual stuff to get that up and running
  3. Inside LeptonXDemoAppWebModule move app.UseErrorPage() outside of the development clause
  4. Start LeptonXDemoApp.HttpApi & LeptonXDemoApp.Web
  5. Go to web project and navigate to /pupsi or something else that obviously does not exist

To "fix" the behavior, go to LeptonXDemoAppGlobalFeatureConfigurator and Change cmsKit.EnableAll() to cmsKit.DisableAll() and repeat above steps.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The CMS module will try to handle the request If there is no error page.

    You can manually add an error page:

  • User Avatar
    0
    jfistelmann created

    Thank you liangshiwei and sorry for the late response.

    I ended up with something like this:

    @model Microsoft.AspNetCore.Diagnostics.ExceptionHandlerFeature
    
    @{
        Layout = "_Layout";
        ViewData["Title"] = "Error";
    }
    
    <div class="container">
        <h1>Oops! Something went wrong.</h1>
        <p>We're sorry, but an error has occurred. Please try again later.</p>
        @if (Model?.Error != null)
        {
            <p>@Model.Error.Message</p>
        }
        <p>If you continue to experience problems, please contact <a href="mailto:support@example.com">support@example.com</a>.</p>
    </div>
    
    

    I was kind of irritated that I needed to provide a page because I assumed that the LeptonXErrorViewComponent would still handle that.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I will check it.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38