Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to have multiple POST method in my .net core web api application.

First action to capture xml from request body
Quote:
[HttpPost]
[Consumes("application/xml")]
public void IngestXML([FromBody]XElement xmlInput)
{..}


second action to capture json from request body
Quote:
[HttpPost)]
[Consumes("application/json")]
public void IngestJson([FromBody]JToken jsonInput)
{...}



Question: Is it possible to route based on query string value?
for example, ../home/index?format=xml to first action method
../home/index?format=json to second action method

What I have tried:

I tried with different routing as below

...Home/index/xml
...Home/index/json

But I am looking for solution to map/route based on query string value
Posted
Updated 27-Jun-18 9:45am

1 solution

 
Share this answer
 
Comments
Member 11906002 27-Jun-18 16:02pm    
Is it possible to route based on query string value?
for example, ../home/index?format=xml to first action method
../home/index?format=json to second action method
Kornfeld Eliyahu Peter 27-Jun-18 16:11pm    
You are doing it wrong...
Use /home/index/xml/... and /home/index/json/... to distinguish the actions...

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