Q:

How to enable the addition of an extra parameter to URL.Action via an Extension method

I am trying to understand how I can add an extra parameter to URL.Action, and have it as part of the resultant link.
Lets assume the following:
myParm = "myTestParameterValue";
@Url.Action("Edit", "Order", new { id=item.Id}, null,myParm)

which would result in:
/Order/Edit/1/myTestParameterValue

I would really appreciate some sample code of the extension method for this Action Sample to see how the parameters are taken in and how the link is generated.
I guess it would start something like:
public static MvcHtmlString Action(this HtmlHelper helper, string actionName, string controllerName, object routeValues, boolean IsHashRequired)

If (IsHashRequired)
{
  String myHash = GetHash();
}

// Pseudocode .... string myNewLink = ... + myHash

Many thanks in advance
EDIT
I need to calculate hash to add to resultant link. A better parameter would be a boolean. I have edited code accordingly.
EDIT2:
    public static IHtmlString Action(this UrlHelper urlHelper, string actionName, string controllerName, object routeValues, string protocol, bool isHashRequired )
{

     if (isHashRequired)
     {
         routeValues["hash"] = "dskjdfhdksjhgkdj"; //Sample value.
     }
     return urlHelper.Action(???); // Resultant URL = /Order/Edit/1/dskjdfhdksjhgkdj
}

EDIT3:
Struggling with :
return urlHelper.Action(actionName, controllerName, routeValues, protocol);

Apparently needs converting to IHtmlString??
EDIT4:
    public static String Action(this UrlHelper urlHelper, string actionName, string controllerName, object routeValues, string protocol, bool isHashRequired )
{

    RouteValueDictionary rvd = new RouteValueDictionary(routeValues);
    if (isHashRequired)
    {
        string token = "FDSKGLJDS";
        rvd.Add("urltoken", token);
    }
     return urlHelper.Action(actionName, controllerName, rvd, protocol); //rvd is incorrect I believe
}

EDIT5
    return urlHelper.Action(actionName, controllerName, rvd, protocol,null);

where 
rvd is the RouteValueDictionary
  hostname is null.
Thanks...

A:

You should consider modifying your routes
Where you have your routing configured add something like this:
routes.MapRoute(
  "hash",                                                            // Route name
  "{controller}/{action}/{id}/{hash}",                               // URL with parameters
  new { controller = "Home", action = "Index", id = "", hash = "" }  // Parameter defaults
);

And use URL.Action like this:
myParm = "myTestParameterValue";
@Url.Action("Edit", "Order", new { id=item.Id, hash = myParm}, null);

You can easily add this with a new extension method class
public static class MyExtensions
{
    public static IHtmlString ActionWithHash(this UrlHelper urlHelper, ....)
    {
         if (hashRequired)
         {
             routeParameters["hash"] = ...
         }
         return urlHelper.Action(...);
    }
}

