asp.net - pass in extra parameters to Web API 2 method -


I have found a web API2 method like this:

  [root (" API / Notifications / {username} ")] // Feature routing, new // [HTTPGATE] Public INMMerable in web API2 & lt; Notification & gt; GetNewNotifications (string username) {return Notification.GetNewNotifications (username); }  

... which I use in javascript w / jquery like this:

  $ GetJSON ('/ api / notifications /' + username)  

What works fine but what is the correct way to pass extra arguments? I have seen different answers and it is unclear to me. I do not think that I want to pass them through the forward slash because they are not hierarchical in nature generally I do this w / querystring parameter, but I Do not know how to take them in server-side.

Thank you!

  / api / notifications / {username}? Posted = class = "post-text" itemprop = "text"> 

true & amp; Received = Incorrect

The query string parameter is handled just like the postal parameters when it comes to data binding, so what you need to do is assign them to your action signature Does it

Public IEnumerable & lt; Notification & gt; GetNewNotifications (string user name, bool send = false, bool received = false) {....}

However, depending on the type of alert it may be more suitable for HTTP header or optional By default, you can define a specific URL that maps to you internally

  / api / notifications / {username} / pending  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -