RedirectToAction 不会更改浏览器 URL [英] RedirectToAction doesnot change the browser URL

查看:32
本文介绍了RedirectToAction 不会更改浏览器 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过执行以下语法从帐户控制器(帐户/登录)重定向到用户/索引.

I was trying to redirect from the Account controller (Account/Login) to User/Index by doing below syntax.

return RedirectToAction("Index", "User");

它显示了正确的视图,但 URL 仍然保留为帐户/登录名.任何人都可以建议我如何实现相同的目标.我尝试了一些来自 google 的搜索,但没有一个对我有用.

it shows up the correct view but the URL still persist as Account/Login. Can anyone suggest how can i achieve the same. I have tried some of the searches from google but none of them works for me.

推荐答案

这是由 jQuery-mobile 引起的问题.默认情况下,jQM 将使表单使用 ajax 调用,因为这是框架中执行页面导航的方式.此处详细介绍了 AJAX 导航.

It's an issue caused by jQuery-mobile. By default, jQM will make forms use ajax calls, as this is how page navigation is performed in the framework. AJAX navigation is explained in more detail here.

解决方案是将 data-ajax="false" 添加到用于初始服务器调用的表单标记中.

The solution is to add data-ajax="false" to the form tag used for the initial server call.

所以你的表单看起来像这样:

So your form would look like this:

@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { data_ajax = "false" }))

这篇关于RedirectToAction 不会更改浏览器 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆