var _config = new HttpConfiguration();
_config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
var _controllerContext = new HttpControllerContext(_config,
new HttpRouteData(new HttpRoute("DefaultApi")),
new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/contacts"));
contactsController.ControllerContext = _controllerContext;
Which I believe complies with my application set up:
routes.MapHttpRoute( name:"DefaultApi", routeTemplate:"api/{controller}/{id}", defaults:new{ id =RouteParameter.Optional} );
However I am still getting the same error:
Value cannot be null. Parameter name: name
</div>
</div>
This may be bug in self host or null value in name paramter is not allowed in self host case. See the diffrence(from source),
web host case,
if (string.IsNullOrEmpty(name))
{
return this.GetVirtualPath(requestContext, values);
}
and self host case,
if (name == null)
{
throw Error......
}
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Url.Route method throwing exception
Apr 06, 2012 12:10 PM|LINK
This may be bug in self host or null value in name paramter is not allowed in self host case. See the diffrence(from source),
web host case,
if (string.IsNullOrEmpty(name)) { return this.GetVirtualPath(requestContext, values); }and self host case,
if (name == null) { throw Error...... }Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD