Unit testing ASP.NET Web API controllers that rely on the UrlHelper
- by cibrax
UrlHelper is the class you can use in ASP.NET Web API to automatically infer links from the routing table without hardcoding anything. For example, the following code uses the helper to infer the location url for a new resource,public HttpResponseMessage Post(User model)
{
var response = Request.CreateResponse(HttpStatusCode.Created, user);
var…