asp.net-mvc – RedirectToAction不工作

我已经在控制器发布后保存了一个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);
                };

解决方法

你显示的代码是正确的。我的猜测是,你没有做标准的POST(例如,重定向不适用于AJAX帖子)。

浏览器将忽略对AJAX POST的重定向响应。如果您需要在AJAX调用返回重定向响应时重定向,则由脚本重定向。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....