title: How do I generate a webapi url from an MVC view?
body: <p>Based on <a href="https://stackoverflow.com/questions/9502306/how-to-create-asp-net-web-api-url">How to create ASP.NET Web API Url?</a></p>
  
  <p>Neither of these plus a few more combinations of them I've tried are working</p>
  
  <pre><code> &lt;li&gt;&lt;a href="@Url.RouteUrl("DefaultApi",new {area=string.Empty,httproute = string.Empty, controller = "corpuserrequest", action="Get"})"&gt;CorpUser&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="@Url.Action("Get","CorpUserRequest",new {area=string.Empty,httproute ="", controller = "CorpUserRequest", action="Get"})"&gt;CorpUser&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>Here's my api config route table:</p>
  
  <pre><code>//https://stackoverflow.com/questions/11407267/multiple-httppost-method-in-mvc4-web-api-controller
          config.Routes.MapHttpRoute(
              name: "ApiReq",
              routeTemplate: "webapi/{controller}/{action}",
             defaults: null,
             constraints: new { action = "Req" }
          );
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional },
              constraints: new
              {
                  id = @"^\d*$",// Only integers 
                  action = "^(?![rR]eq)$" //anything except req or Req
              }
          );
  </code></pre>
  
  <p>Why isn't the routing working? The RouteUrl returns empty string or null, the Action returns </p>
  
  <pre><code>&lt;a href="http://localhost:11601/CorpUserRequest/Get"&gt;
  </code></pre>
  
  <p>instead of what the actual url should be <code>http://localhost:11601/api/CorpUserRequest</code></p>