Accessing the query string in ASP.Net Web Api?

Even though @Kiran Challa’s answer is correct, there are few situations that you might prefer to get URL parameters directly from the URL. in those scenarios, try this: using System.Net.Http; var allUrlKeyValues = ControllerContext.Request.GetQueryNameValuePairs(); string p1Val = allUrlKeyValues.LastOrDefault(x => x.Key == “p1”).Value; string p2Val = allUrlKeyValues.LastOrDefault(x => x.Key == “p2”).Value; string p3Val = allUrlKeyValues.LastOrDefault(x => … Read more

Angular: append query parameters to URL

This could be achieved by using the Router class: Using a component: import { Router, ActivatedRoute } from ‘@angular/router’; @Component({}) export class FooComponent { constructor( private _route: ActivatedRoute, private _router: Router ){} navigateToFoo(){ // changes the route without moving from the current view or // triggering a navigation event, this._router.navigate([], { relativeTo: this._route, queryParams: { … Read more

Semicolon as URL query separator

The W3C Recommendation from 1999 is obsolete. The current status, according to the 2014 W3C Recommendation, is that semicolon is now illegal as a parameter separator: To decode application/x-www-form-urlencoded payloads, the following algorithm should be used. […] The output of this algorithm is a sorted list of name-value pairs. […] Let strings be the result … Read more

Objective-C: How to add query parameter to NSURL?

Since iOS 7 you can use NSURLComponents that is very simple to use. Take a look on these examples: Example 1 NSString *urlString = @”https://mail.google.com/mail/u/0/?shva=1#inbox”; NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString]; NSLog(@”%@ – %@ – %@ – %@”, components.scheme, components.host, components.query, components.fragment); Example 2 NSString *urlString = @”https://mail.google.com/mail/u/0/?shva=1#inbox”; NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString]; if … Read more

How to extract query parameters with ui-router for AngularJS?

See the query parameters section of the URL routing documentation. You can also specify parameters as query parameters, following a ‘?’: url: “/contacts?myParam” // will match to url of “/contacts?myParam=value” For this example, if the url is /contacts?myParam=value then the value of $state.params will be: { myParam: ‘value’ }

Query string not working while using attribute routing

I was facing the same issue of ‘How to include search parameters as a query string?’, while I was trying to build a web api for my current project. After googling, the following is working fine for me: Api controller action: [HttpGet, Route(“search/{categoryid=categoryid}/{ordercode=ordercode}”)] public Task<IHttpActionResult> GetProducts(string categoryId, string orderCode) { } The url I tried … Read more