I am developing a MVC 3 application for a corporate intranet site and I am having some issues with the URL helper sometimes not producing correct URLs. The application is being accessed through an access manager application that is controlled by our IT department which basically provides a standardized URL so that the user does not need to know any information about the server. For example, to access the application directly on the server, I would visit:
http://philsserver/App
Through the access manager, I would use the URL provided by the IT department:
http://secureintranet/PHILSAPP/App/
I am using the MVC URL helper in several places in my application - the issue is that sometimes the "PHILSAPP" part is left out - when I use it within an "<a>
" link, it works, but when I use it in elsewhere, it does not.
For example, the code:
<a href="@Url.Action("Index", "FormsAndTemplates")">
correctly creates the link as:
<a href="/PHILSAPP/App/FormsAndTemplates">
.
The following code:
@Html.TextBox("lastName", ViewBag.LastName as string, new { @class = "input-mini", @autocomplete = Url.Action("QuickSearch", "Employee") })
produces:
<input autocomplete="/App/Employee/QuickSearch" class="input-mini" id="lastName" name="lastName" type="text" value="" />
Notice that this URL does not contain the "PHILSAPP" part. This also happens if I use the URL helper in javascript or just about anywhere other than an "<a>
" tag. Does anyone have any idea why this would be happening? As far as I can tell, both calls to Url.Action are pretty much the same so I cannot figure out why this is happening. I apologize if this question has already been answered but I was not able to find any information about someone having a similar problem. Thanks in advance for any assistance.
Update: As requested, my routes are below:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
Update 2: The access manager being used is Tivoli Identity Manager if that gives anyone any clues.
Url.Action
always generate the correct url. But insidea href
your reverse proxy modifies it. But it does not correctly detects the url inside theautocomplete
attribute and leave it unchanged. So I should suggests to contact your IT to inform about your reverse proxy configuration. – Tails