Reputation: 4592
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
Upvotes: 0
Views: 442
Reputation: 1038930
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.
Upvotes: 2