Hacker News new | ask | show | jobs
by Xdes 4412 days ago
You can allow non-administrator access using netsh[1] as an administrator. That way you don't need to run VS as admin.

    netsh http add urlacl url=http://+:8080/ user=DOMAIN\username
You don't need attributes based routing in this example. Convention based routing is built into WebAPI.

For the Delete method you can return an HttpStatusCode instead of throwing an exception.

    public IHttpActionResult Delete(int Id)
    {
        var result = (from b in ourbooks
                      where b.Id == Id
                      select b).FirstOrDefault();

        ourbooks.Remove(result);
        return StatusCode(HttpStatusCode.Accepted);
    }
Also check out the OWIN self host tutorial [2].

[1] https://github.com/NancyFx/Nancy/wiki/Hosting-nancy-with-owi...

[2] http://www.asp.net/web-api/overview/hosting-aspnet-web-api/u...