Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to give custom name to post handler in Razor Pages?

I’m implementing Stripe payments on my website.

They say to create the following method on my page.

[HttpPost("create-checkout-session")]
public ActionResult CreateCheckoutSession()
{
    // ...
}

However, this is MVC syntax and I’m using Razor Pages.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

public IActionResult OnPost()
{
    // ...
}

I know how to use named handlers, but I don’t know how to give my method the name create-checkout-session.

>Solution :

The name create-checkout-session is just a recommendation, not a requirement. The main thing you need to do is have your frontend code call a route on your server that will create a Checkout Session and then perform the next required steps, which vary depending on how exactly you’re integrating Stripe.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading