我已经在控制器发布后保存了一个RedirectToAction,但URL并没有改变,重定向似乎不起作用。我需要补充说,当我调试时,重定向会进入控制器的action方法。它不会更改URL或导航到索引视图…
public ViewResult Index() { return View("Index",new Trainingviewmodel()); } public ActionResult Edit() { //save the details and return to list return RedirectToAction("Index"); }
我究竟做错了什么 ?
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.js/{*pathInfo}"); routes.IgnoreRoute("{*favicon}",new { favicon = @"(.*/)?favicon.ico(/.*)?" }); routes.MapRoute( "Default",// Route name "{controller}/{action}/{id}",// URL with parameters new { controller = "Home",action = "Index",id = "" } // Parameter defaults ); }
// JQUERY CALLS
this.SynchValuesToReadOnly = function() { window.location = $('#siteRoot').attr('href') + 'Sites/'; }; this.OnSiteEdit = function() { //post back to the server and update the assessment details var options = { target: '',type: 'post',url: '/Site/Edit',beforeSubmit: othis.validate,success: othis.SynchValuesToReadOnly }; $('#uxSiteForm').ajaxSubmit(options); };