Asp.net mvc 4 MVC重定向到jquery mobile中的操作使用
事情是这样的。我有一个如下所示的控制器Asp.net mvc 4 MVC重定向到jquery mobile中的操作使用,asp.net-mvc-4,Asp.net Mvc 4,事情是这样的。我有一个如下所示的控制器 public class StoreController : Controller { public ActionResult Index() { return View(); } public ActionResult Create() { return View(); } [HttpPost] public A
public class StoreController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(string id, string name)
{
//... some WCF logic here.
return RedirectToAction("Index");
}
}
我的问题是post-Create方法。当它调用RedirectToAction()时,我在web浏览器中看到索引页,但URL仍然显示http://.../Store/Create
,如果我按下浏览器刷新按钮,则会得到创建视图而不是索引视图。没有使用AJAX。正常的Html.BeginForm(“创建”、“存储”、FormMethod.Post)
我的路由配置如下:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
有什么想法吗?0_0
编辑1
也许我应该指出,我使用jquery mobile
编辑2
我的观点,以防万一
@model WebApp.Models.StoreCreateModel
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm("Create", "Store", FormMethod.Post))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Store</legend>
@Html.Partial("_StoreEditFields", this.Model)
<p>
<input type="submit" value="Create" />
<a href="@Url.Action("Index")" data-role="button">Back to list</a>
</p>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
@model WebApp.Models.StoreCreateModel
@{
ViewBag.Title=“创建”;
}
@使用(Html.BeginForm(“创建”、“存储”、FormMethod.Post))
{
@Html.ValidationSummary(true)
商场
@Html.Partial(“\u StoreEditFields”,this.Model)
}
@节脚本{
@Scripts.Render(“~/bundles/jqueryval”)
}
你能发布你的路线吗?@四十二如果你所说的路线是指路线配置,那么我已经更新了我的问题。这是该方法中唯一的一行代码。这里还有一些您没有包含的内容,因为您发布的代码没有任何问题。你确定在Create方法中没有只返回索引视图而不返回RedirectToAction的代码路径吗?我正在阅读关于jquery mobile的文章。看起来它确实在幕后使用了AJAX。我现在只需要找出解决问题的方法。调试时,是返回RedirectToAction(“Index”)代码>实际被击中?