0

I am moving some functions to .net 5 isolated process but I am not sure about how to extract data using the new HttpRequestData in .net core I could do req.Query["blah"]

How do you do it in .net 5 with HttpRequestData?

.net 3.1

public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
        string fieldA = req.Query["fieldA"];
        string fieldB = req.Query["fieldB"];

        //etc...        
}

.net 5

 public  async Task<IActionResult>  Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req, FunctionContext executionContext)
 {
        
        string fieldA = //????  req.Query["fieldA"];
        string fieldB = //???req.Query["fieldB"];

            //etc..             
 }
developer9969
  • 4,628
  • 6
  • 40
  • 88

1 Answers1

2

HttpRequestData.Url Property has Uri.Query Property.

You can use

var queryDictionary = 
    Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query);

As suggested in Parse and modify a query string in .NET Core

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170