Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

protocol & host name ignored when creating action link #926

Closed
johnciliberti opened this issue Aug 2, 2014 · 3 comments
Closed

protocol & host name ignored when creating action link #926

johnciliberti opened this issue Aug 2, 2014 · 3 comments
Assignees
Milestone

Comments

@johnciliberti
Copy link

On MVC 6 tried using ActionLink to create a link that includes the host name and protocal using the following code:
@Html.ActionLink("Secure Page","SecurePage","Home","https","mywebsite","",null,null)
results:
<a href="/Home/Contact">Secure Page</a>

On MVC 5 this same code results in:
<a href="https://mywebsite/Home/SecurePage">Secure Page</a>

Looking at the code in HtmlHelper.cs it looks like you are completely ignoring the parameters

    public HtmlString ActionLink(
            [NotNull] string linkText,
            string actionName,
            string controllerName,
            string protocol,
            string hostname,
            string fragment,
            object routeValues,
            object htmlAttributes)
        {
            var url = _urlHelper.Action(actionName, controllerName, routeValues);
            return GenerateLink(linkText, url, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
        } 
@dougbu
Copy link
Member

dougbu commented Aug 2, 2014

/cc @rynowak ? looks like protocol, hostname and fragment parameters are all ignored.

@rynowak
Copy link
Member

rynowak commented Aug 4, 2014

@dougbu yes, the htmlhelper should be calling

_urlHelper.Action(actionName, controllerName, routeValues, protocol, hostname, fragment);

@kichalla
Copy link
Member

Fixed with commit: fdeff11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants