【发布时间】:2014-02-03 21:50:38
【问题描述】:
所以我在 C# 中有一个很长的函数。 我的表单包含一个显示字符串的局部视图。简单的。 提交表单后,控制器将触发 long 函数。 我试图做的是在该部分视图中显示一个解释该过程如何进行的文本。 但我不知道如何在不停止我的功能的情况下进行 ajax 调用来刷新。 这是我所拥有的:
部分:
@model System.String
Performing: @Model.ToString()
主视图:
<div id="divLoading" style="margin: 0px; padding: 0px; position: fixed; right: 0px;
top: 0px; width: 100%; height: 100%; background-color: #666666; z-index: 30001;
opacity: .8; filter: alpha(opacity=70);display:none">
<p style="position: absolute; top: 30%; left: 45%; color: White;">
Saving, please wait... <img src="../../Content/images/ajax-loading.gif">
</p>
<p style="position: absolute; top: 37%; left: 45%; color: White;">
@Html.Partial("_ProgressList", completedProgress);
</p>
</div>
控制器:
[HttpPost]
[ValidateInput(false)]
public ActionResult longFunction(FormCollection collection)
{
PartialView("_Partial", response); //Update here but continue execution
...
...
}
这可能吗?
【问题讨论】:
-
HTTP 不是这样工作的。考虑使用 Signalr。
标签: c# ajax asp.net-mvc razor partial-views