Open Closed

Redirect to Page not working #4258


User avatar
0
darutter created
  • ABP Framework version: v5.3.0
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

I am trying to redirect to a page in my OnPost method but the page never appears. The call to the RedirectToPage() doesn't throw an exception but in the logs this is what I get: 2022-12-29 14:32:15.195 -06:00 [INF] Request finished HTTP/2 POST https://localhost:44386/TenantRequests/CreateModal application/x-www-form-urlencoded;+charset=UTF-8 476 - 302 - - 645.5495ms 2022-12-29 14:32:15.198 -06:00 [INF] Request starting HTTP/2 GET https://localhost:44386/PatriotPayment - - 2022-12-29 14:32:15.444 -06:00 [INF] Executing endpoint '/PatriotPayment/Index' 2022-12-29 14:32:15.451 -06:00 [INF] Route matched with {page = "/PatriotPayment/Index", area = "", action = "", controller = ""}. Executing page /PatriotPayment/Index 2022-12-29 14:32:15.451 -06:00 [INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy 2022-12-29 14:32:15.724 -06:00 [INF] Executing an implicit handler method - ModelState is "Valid" 2022-12-29 14:32:15.724 -06:00 [INF] Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult. 2022-12-29 14:32:15.752 -06:00 [DBG] Added bundle 'Lepton.Global' to the page in 16.40 ms. 2022-12-29 14:32:15.754 -06:00 [INF] Authorization failed. These requirements were not met: PermissionRequirement: SettingManagement.Emailing 2022-12-29 14:32:15.754 -06:00 [INF] Authorization failed. These requirements were not met: PermissionRequirement: AbpIdentity.SettingManagement 2022-12-29 14:32:15.755 -06:00 [INF] Authorization failed. These requirements were not met: PermissionRequirement: LeptonThemeManagement.Settings 2022-12-29 14:32:15.755 -06:00 [INF] Authorization failed. These requirements were not met: PermissionRequirement: AbpAccount.SettingManagement 2022-12-29 14:32:15.872 -06:00 [DBG] Added bundle 'Lepton.Global' to the page in 112.99 ms. 2022-12-29 14:32:15.873 -06:00 [INF] Executed page /PatriotPayment/Index in 422.6334ms 2022-12-29 14:32:15.874 -06:00 [INF] Executed endpoint '/PatriotPayment/Index' 2022-12-29 14:32:15.874 -06:00 [INF] Request finished HTTP/2 GET https://localhost:44386/PatriotPayment - - - 200 - text/html;+charset=utf-8 675.7313ms The TenantRequests/CreateModal is the page that calls RedirectToPage("/PatriotPayment"). A shown, the ModelState is valid and eventually I get a 200 result but the page never shows. There is a set of Authorization failed errors that always show up that doesn't make any sense to me. There is no authorization on the page as it is a plain .cshtml file with no calls to backend processes.

The OnPost() method is simple:

        public async Task<IActionResult> OnPostAsync()
        {
            try
            {
                await _tenantRequestsAppService.CreateAsync(TenantRequest);
                return RedirectToPage("/PatriotPayment/Index");
            }
            catch(Exception ex)
            {
                Debug.WriteLine(ex);
                return NoContent();
            }

and the .cshtml of the page that is being called is also simple:
@page
@using PatriotTracker.Web.Pages.TenantRequests
@using PatriotTracker.Web.Menus
@using Microsoft.AspNetCore.Mvc.Localization
@using PatriotTracker.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@inject IHtmlLocalizer<PatriotTrackerResource> L
@inject IPageLayout PageLayout
@model PatriotTracker.Web.Pages.TenantRequests.SubmitPaymentModel
@{
}
<abp-card id="TenantRequestSubmitPayment">
    <abp-card-body>
        <h3>Payment for your subscription is $50.00 / month. If you agree with this purchase, click the "Purchase" button.</h3>

                <form id="SubscribeForm" autocomplete="off" method="post">
                    <div class="col-12" style="align-content:center">
                        <abp-button button-type="Primary" type="submit" text="Purchase"/>
                    </div>
                </form>
    </abp-card-body> 
</abp-card>

I've tried several different Redirect methods and they all seem to result in the same issue. Any assistance is appreciated.


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

    Hi,

    The code seems no problem, I think maybe there is some other problem. Could you share a minimal reproducible project with me? thanks. shiwei.liang@volosoft.com

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15