0

I have a view with a link which is suppose to fire a get request:

<span style="margin-right: 20px;">@Html.Hyperlink("http://localhost:59536" + pr.Url, pr.Name)</span>

<span style="margin-right: 20px;">@Html.ActionLink(pr.Name, "LoginExternal", new { url = pr.Url, state = pr.State })</span>

When I use custom html helper generating a hyperlink in the view everything works fine. If I use a second method which calls action method in the controller get request is never released:

    public async Task LoginExternal(string url, string state)
    {
        var client = new HttpClient { BaseAddress = new Uri(uri) };
        var response = await client.GetAsync(url);
        response.EnsureSuccessStatusCode();
    }

What am I missing in the controller action method

tereško
  • 57,247
  • 24
  • 95
  • 149
Bartosz
  • 4,412
  • 11
  • 41
  • 67

1 Answers1

2

It appears that you are attempting to generate a link to a Web API method using Html.ActionLink. You could use the Html.RouteLink and specify the httproute="" value:

@Html.RouteLink(
    pr.Name, 
    "DefaultApi", 
    new { 
        httproute = "", 
        controller = "LoginExternal", 
        url = pr.Url, 
        state = pr.State
    }
)

You might need to adjust the name of the route if DefaultApi is not the Web API route you have.

Darin Dimitrov
  • 994,864
  • 265
  • 3,241
  • 2,902