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
  • 58,060
  • 25
  • 98
  • 150
Bartosz
  • 4,542
  • 11
  • 43
  • 69

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
  • 1,023,142
  • 271
  • 3,287
  • 2,928