As nemesv pointed out above, the answer was that the Url.Action
method was always generating the URL as /App/... but the access manager application would recognize certain tags (such as <a href="/App/...">
, <form action="/App/...">
, etc.) and would add the /PHILSAPP to the beginning. The solution I am exploring is to write some extension methods for the UrlHelper
and HtmlHelper
to generate absolute URLs rather than relative URLs where the host name including the /PHILSAPP will be specified in the web.config file. If anyone still has any other suggestions to solve this I would be happy to hear them but otherwise I am satisfied with using this as a work-around.
Some boilerplate code to start with:
namespace MvcApplicationNameSpace
{
/// <summary>
/// Extension methods to the UrlHelper class for generating absolute URLs using
/// Web.config settings
/// </summary>
public static class UrlHelperExtensions
{
private static string BaseUrl
{
get
{
return System.Configuration.ConfigurationManager.AppSettings["BaseUrl"];
}
}
/// <summary>
/// Generates a string for the absolute URL to an action method
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url)
{
return BaseUrl + url.Action();
}
/// <summary>
/// Generates a string for the absolute URL to an action method with the
/// specified name
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName)
{
return BaseUrl + url.Action(actionName);
}
/// <summary>
/// Generates a string for the absolute URL to an action method with the
/// specified name and route values
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <param name="routeValues"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName, object routeValues)
{
return BaseUrl + url.Action(actionName, routeValues);
}
/// <summary>
/// Generates a string for the absolute URL to an action method with the
/// specified name and route values
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <param name="routeValues"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName, RouteValueDictionary routeValues)
{
return BaseUrl + url.Action(actionName, routeValues);
}
/// <summary>
/// Generates a string for the absolute URL to an action method and
/// controller
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <param name="controllerName"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName, string controllerName)
{
return BaseUrl + url.Action(actionName, controllerName);
}
/// <summary>
/// Generates a string for the absolute URL to an action method and
/// controller, including route values
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <param name="controllerName"></param>
/// <param name="routeValues"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName, string controllerName, object routeValues)
{
return BaseUrl + url.Action(actionName, controllerName, routeValues);
}
/// <summary>
/// Generates a string for the absolute URL to an action method and
/// controller, including route values
/// </summary>
/// <param name="url"></param>
/// <param name="actionName"></param>
/// <param name="controllerName"></param>
/// <param name="routeValues"></param>
/// <returns></returns>
public static string AbsoluteAction(this UrlHelper url, string actionName, string controllerName, RouteValueDictionary routeValues)
{
return BaseUrl + url.Action(actionName, controllerName, routeValues);
}
}
}