I'm trying to get the querystring that is in the browser, an example /UserHome/UserProfile?username=dangercoder. I'm working in WebApi controller
from the following url i want to get "dangercoder" so I can use the dangercoder username in my AddPost method that is in my Web Api
what i've done so far in the method (the reciever id can be hardcoded but ofcourse i want it to be dangercoder username converted to an id.
[System.Web.Http.HttpPost]
public IHttpActionResult AddPost(Post post)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var user = User.Identity.Name;
post.SenderID = UserRepository.GetUserId(user);
// QueryString that returns username in the parameter below.
post.RecieverID = UserRepository.GetUserId();
PostRepository.AddNewPost(post);
return CreatedAtRoute("DefaultApi", new { id = post.ID }, post);
}