Skip to content

How to create a route with both GET and POST method ? #79

Answered by scottoffen
pubpy2015 asked this question in Q&A
Discussion options

You must be logged in to vote

You can also use multiple Route attributes on the method.

[RestRoute("Get", "/hello")]
[RestRoute("Post", "/hello")]
public async Task HelloWorld(IHttpContext context)
{
    await context.Response.SendResponseAsync($"Hello, world!");
}

However, you would have to differentiate in the method if you want the behavior to change depending on whether the method is POST or GET.

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by scottoffen
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #73 on October 01, 2021 04:32.