You could use either of the following to generate links to Web API:
@Url.HttpRouteUrl("DefaultApi", new {controller = "corpuserrequest"})
@Url.RouteUrl("DefaultApi", new { httproute = true, controller = "corpuserrequest"})
Usually you would use option 1.
, but sometimes you might need to use 2.
like in the following post (this post doesn't necessarily use RouteUrl
, but the idea is that in places where you do not have a convenient extension like HttpRouteUrl
, in this case Html.BeginForm
, you can use httproute=true
to indicate that you are indeed trying to generate a url to a Web API route)
ASP.Net WebApi: Invalid URL generated in BeginForm