Click here to Skip to main content
15,881,561 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a redirect to my API, the order-id is hyphenated, but my C# REST API accept order_id with underscore, how do I accepted the first?

eg.

https://redirect-url/?order-id=xxxx&token=xxxxx

HELP please

What I have tried:

this the what I have

[HttpGet("ExpressPay")]
public IActionResult ExpressPay(string token, string order_id)
Posted
Updated 16-Sep-21 2:53am

1 solution

Try:

.NET Core / .NET 5:
C#
[HttpGet("ExpressPay")]
public IActionResult ExpressPay(string token, [FromQuery(Name = "order-id")] string order_id) 
Routing to controller actions in ASP.NET Core | Microsoft Docs[^]

ASP.NET Web API v2:
C#
[HttpGet("ExpressPay")]
public IActionResult ExpressPay(string token, [FromUri(Name = "order-id")] string order_id) 
Parameter Binding in ASP.NET Web API - ASP.NET 4.x | Microsoft Docs[^]
 
Share this answer
 
Comments
Paa Kofi 16-Sep-21 9:47am    
many thanks
Paa Kofi 16-Sep-21 9:47am    
many thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900