UPDATED: Final implementation of CustomWorkboxFrom looks like above:
using System;
using System.Collections.Generic;
using System.Linq;
using Sitecore;
using Sitecore.Text;
using Sitecore.Web;
using Sitecore.Workflows;
using Sitecore.Workflows.Simple;
namespace Test
{
public class CustomWorkboxForm : Sitecore.Shell.Applications.Workbox.WorkboxForm
{
/// <summary>Gets or sets the offset(what page we are on).</summary>
/// <value>The size of the offset.</value>
private OffsetCollection Offset = new OffsetCollection();
/// <summary>Refreshes the page.</summary>
protected override void Refresh()
{
this.Refresh(null);
}
/// <summary>Refreshes the page.</summary>
/// <param name="urlArguments">The URL arguments.</param>
protected new void Refresh(Dictionary<string, string> urlArguments)
{
UrlString urlString = new UrlString(WebUtil.GetRawUrl());
urlString["reload"] = "1";
if (urlArguments != null)
{
foreach (KeyValuePair<string, string> urlArgument in urlArguments)
urlString[urlArgument.Key] = urlArgument.Value;
}
var url = WebUtil.GetFullUrl(urlString.ToString());
var uri = new Uri(url);
var clean = uri.GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port,
UriFormat.UriEscaped);
Context.ClientPage.ClientResponse.SetLocation(clean);
}
/// <summary>
/// Workflow completion callback to refresh the counts of items in workflow states.
/// </summary>
/// <param name="args">The arguments for the workflow execution.</param>
[UsedImplicitly]
private void WorkflowCompleteStateItemCount(WorkflowPipelineArgs args)
{
IWorkflow workflowFromPage = GetWorkflowFromPage();
if (workflowFromPage == null)
return;
int itemCount = workflowFromPage.GetItemCount(args.PreviousState.StateID);
if (PageSize > 0 && itemCount % PageSize == 0)
{
int num = Offset[args.PreviousState.StateID];
if (itemCount / PageSize > 1 && num > 0)
Offset[args.PreviousState.StateID]--;
else
Offset[args.PreviousState.StateID] = 0;
}
Refresh(workflowFromPage.GetStates().ToDictionary((state => state.StateID), (state => Offset[state.StateID].ToString())));
}
private class OffsetCollection
{
public int this[string key]
{
get
{
if (Context.ClientPage.ServerProperties[key] != null)
return (int)Context.ClientPage.ServerProperties[key];
UrlString urlString = new UrlString(WebUtil.GetRawUrl());
int result;
if (urlString[key] != null && int.TryParse(urlString[key], out result))
return result;
return 0;
}
set
{
Context.ClientPage.ServerProperties[key] = (object)value;
}
}
}
}
}
Unfortunately, if you still want to remove the port from URL, you need to include some implementation of private method defined in base class.