Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

RedirectToPage(page, handler) inside a view redirects to the page but not the handler #6436

Closed
halter73 opened this issue Jun 22, 2017 · 1 comment

Comments

@halter73
Copy link
Member

/Pages/TestPage.cshtml

@page

@functions
{
    public IActionResult OnGet()
    {
        return RedirectToPage("/TestPage2", "Foo");
    }
}

/Pages/TestPage2.cshtml.cs

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace WebApplication5.Pages
{
    public class TestPage2Model : PageModel
    {
        public string Test { get; set; } = "DefaultHandler";

        public IActionResult OnPost()
        {
            return RedirectToPage("/TestPage2", "Foo");
        }

        public void OnGetFoo()
        {
            Test = "FooHandler";
        }
    }
}

/Pages/TestPage2.cshtml

@page "{handler?}"
@model TestPage2Model

<p>@Model.Test</p>

<a asp-page="TestPage2" asp-page-handler="Foo">TestPage2Foo</a>

<form method="POST">
    <input type="submit" />
</form>

To reproduce this issue, take the following steps:

  • Ensure the files listed above are in your MVC 2.0.0-preview2 project.
  • Run the project and navigate to /TestPage

Expected Behavior:

/TestPage should redirect to /TestPage2/Foo, and the response body should contain "FooHandler".

Actual Behavior:

/TestPage redirects to just /TestPage, and the response body contains "DefaultHandler".

Note that if you submit the form on /TestPage2, the TestPage2.OnPost() handler is invoked and RedirectToPage("/TestPage2", "Foo") successfully redirects to /TestPage2/Foo which contains "FooHandler" as expected. The TestPage2Foo link also points to /TestPage2/Foo.

@Eilon
Copy link
Member

Eilon commented Jul 5, 2017

This certainly seems suspicious, but it would be good to see if there's isn't just something odd going on w/ ambient values.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants