Still kinda new to ASP.net and I have this strange problem. Its a very basic scenario but something is up and I can't figure it out. Deploy should return a view named Deploy that is typed to the model CompiledAppModel. However, when you click install in the view it never leaves the page despite calling the return View() method. Any ideas?
Here is my controller:
[HttpPost]
public ActionResult Deploy(string key_name, string custom_folder = "")
{
string userId = Membership.GetUser().ProviderUserKey.ToString();
UserDataModel user_info = _user_data_service.getUserDataByPrimaryIDNoDB(userId, HttpContext.Cache);
log.Trace("Deploy was called. key_name:" + key_name + " UID: " + user_info.UID);
// first we'll call the info to install remote application
bool serviceInstall = _fms_app_service.DeployFmsApp(user_info, key_name, custom_folder);
// then we'll call to generate client side info
bool clientInstall = _fms_app_service.CompileClientApp(user_info, key_name);
var model = _fms_app_service.getInstalledAppInfo(user_info, key_name);
if (serviceInstall && clientInstall)
{
return RedirectToAction("Deploy", model);
}
return View("Error");
}
and my view:
@model IEnumerable<Models.Applications.FmsAppModel>
@foreach (var item in Model) {
<div class="col">
<h2>@Html.DisplayFor(modelItem => item.friendly_name)</h2>
<p>@Html.DisplayFor(modelItem => item.app_description)</p>
<p><strong>Tags:</strong> @Html.DisplayFor(modelItem => item.app_type)</p>
<a href="#" class="btn btn-primary install-app" data-key-name="@(item.key_name)">Install</a>
@Html.ActionLink("Details", "Detailss", new { id=item.app_id })
</div>
}
</div>
<script type="text/javascript">
(function () {
$('.install-app').on('click', function (e) {
e.preventDefault();
var data_key_name = $(this).data('key-name');
//ajax install app
$.ajax({
type: "POST",
url: '@Url.Action("Deploy")',
data: {
key_name: data_key_name
}
});
});
})();
</script>
And the model.
public class CompiledAppModel
{
[Display(Name = "Admin URL")]
public string adminURL { get; set; }
[Display(Name = "Viewer URL")]
public string viewerURL { get; set; }
[Display(Name = "Embed URL")]
public string embedURL { get; set; }
}