asp.net-mvc – RedirectToAction不工作
发布时间:2020-12-15 18:48:06 所属栏目:asp.Net 来源:网络整理
导读:我已经在控制器发布后保存了一个RedirectToAction,但URL并没有改变,重定向似乎不起作用。我需要补充说,当我调试时,重定向会进入控制器的action方法。它不会更改URL或导航到索引视图… public ViewResult Index() { return View("Index",new TrainingView
我已经在控制器发布后保存了一个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调用返回重定向响应时重定向,则由脚本重定向。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-core – RenderPartial()在ASP.Net 5 MVC 6中的位置
- asp.net – 表单验证忽略默认文档
- 具有前缀的控件的Asp.Net MVC2 Clientside验证问题
- asp.net-mvc – 如何将变量传递给ASP.NET MVC应用程序中的自
- asp.net – Azure SqlException:服务器上的数据库当前不可
- asp.net jquery用文本框添加行(克隆行)并动态下拉
- asp.net-mvc – 仅将值从EditorTemplate传递到其布局模板,在
- asp.net-mvc – 一种在MVC环境中处理返回URL的智能方法
- IIS上的ASP.NET Core 2.0错误502.5
- asp.net – 用于创建事件处理程序存根的Visual Studio键盘快
推荐文章
站长推荐
- ASP.NET中自动HtmlEncode
- asp.net-core – 获取具有指定角色的用户
- asp.net-mvc – 由Url.Action生成的Asp.Net MVC错
- 使用ASP.NET Core进行Ws-Federation身份验证
- asp.net-mvc – 如何在ASP.net MVC 4 RouteConfi
- 如何说服我的管理员从ASP.NET 2.0升级到3.5?
- razor – 从ASP.net Core 2中的视图访问自定义Ap
- ASP.NET Web窗体是否阻止双击提交?
- asp.net – Orchard CMS如何进行日志记录?
- asp.net-mvc – 如何在@ Html.TextBox mvc4中添加
热点阅读