Request is always null in web api?

Viewed 9010

I have a Web API with a Base Controller, I wanna get requested controller name from Request.GetRouteData().Values["controller"], as the following code :

public class BaseApiController : ApiController
{
    protected string EntityName;

    public BaseApiController()
    {
        //Request is null
        EntityName = Request.GetRouteData().Values["controller"] as string;
    }
}

But Request is always null in above code.
What's wrong with above code?

3 Answers
Related