I’m having a perplexing issue related to a small intranet application I’m trying to setup.
I have it going in IIS, using Windows Auth. Everything is running as it should, except for this one thing.
On my settings page, I have a list of “User Admins”, who approve or deny things submitted by the rest of the users. I have this set up such that I can add or remove admins from within the website itself. This is all working fine on my local machine in VS2010, however, I tried to push up to my dev-test server and hit a snag: Whenever I click the “Add Admin” link, the server returns a 503 error in the javascript console when attempting to hit “Settings/UserAdminRow”.
This has me baffled as it works fine locally, and the rest of the site is perfectly operational. There are no errors in any of my logs (custom ones set up for this app, the windows event logs, etc).
Here is the Razor code and javascript for the settings page.
<ul id="adminEditor" style="list-style-type: none">
@foreach (string userAdmin in Model.UserAdmins)
{
Html.RenderPartial("UserAdminsEditor", userAdmin);
}
</ul>
<a id="addAnother">@StringTable.GetString("AddAdmin")</a>
<script type="text/javascript" language="javascript">
<!--
$("#addAnother").click(function () {
$.get('Settings/UserAdminRow', function (template) {
$("#adminEditor").append(template);
});
});
-->
</script>
Here’s what it calls to:
public ActionResult UserAdminRow()
{
return PartialView("UserAdminsEditor");
}
And here’s the “UserAdminsEditor” razor code.
@model string
<li style="padding-bottom: 15px">
@using (Html.BeginCollectionItem("UserAdmins"))
{
@Html.TextBoxFor(model => model)
<a href="#" onclick="$(this).parent().remove();">@StringTable.GetString("Remove")</a>
}
</li>
BeginCollectionItem is a reference to an extension method I found here: http://ivanz.com/2011/06/16/editing-variable-length-reorderable-collections-in-asp-net-mvc-part-1/
Any suggestions? I’m completely stumped.
Simple fix for this. Changed the url in the
$.getcall from ‘Settings/UserAdminRow’ to ‘./Settings/UserAdminRow/’ and it works fine. All I needed to do was add the period.