Skip to content

PageRemote attribute has a bug #39864

@miladahmadi33

Description

@miladahmadi33

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using .NET 6 and razor pages.
[PageRemote] attribute in POST method doesn't send __requestverificationtoken to server and I get error 400.

Expected Behavior

PageRemote attribute doesn't work and doesn't send __requestverificationtoken filed on post method.
This is my ViewModel

public class AddCategory
{
    [PageRemote(PageName = "Category", PageHandler = "CheckForTitle",
    HttpMethod = "POST",
    AdditionalFields = "__RequestVerificationToken",
    ErrorMessage = "This title is duplicate")]
    public string Title { get; set; } = null!;
 }

And this is my handler

public class CategoryModel : PageModel
{
    [BindProperty]
    public AddCategory Category { get; set; }

    public void OnGet()
    {
    }

    public IActionResult OnPostCheckTitle(AddCategory category)
    {
        return new JsonResult(category.Title == "a");
    }
}

GET method is ok and everything is fine, but in POST method __requestverificationtoken doesn't send to the server and I get error 400.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.101

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions