RedirectToAction不工作在一个特定的动作(处理)动作、工作、RedirectToAction

2023-09-10 19:30:22 作者:羡鱼

我有Ajax调用,它将调用呼吁表单提交控制器中的提交行动.. 在我得到了类似下面......

I had Ajax call which will call an action called "submit" on form submission in a controller.. in that i got something like below....

如果(CSConfigurationMgr.IsMobileUrl(Request.UrlReferrer.AbsoluteUri.PathFromURL()))             返回RedirectToAction(家,手机,新{成功= TRUE});

if (CSConfigurationMgr.IsMobileUrl(Request.UrlReferrer.AbsoluteUri.PathFromURL())) return RedirectToAction("home", "mobile", new { success = true});

它会做的是重定向到网站首页,并纷纷展示三江源消息...

what it will do is redirects to hompage and have to display thankyou message...

我试过只给网址为XXXXXXX /手机/家?成功=真它的工作如我所料。

i tried just giving url as xxxxxxx/mobile/home?success=true it worked as i expect..

我得到如此的条件,会返回一个说法,但我没有重定向到新的一页......

i am getting true for that condition and going to return statement but i am not redirect to the new page ......

我已经检查航线没问题 我已经通过将redirecttoaction在它工作得很好,我重定向到新的一页一些其他操作检查。但它不工作在这里......

i had checked routes no problem in that i had checked by placing the redirecttoaction in some other action it worked fine i am redirected to new page . But it is not working in here .....

错误:能否HTTP标头已被送往后没有出现重定向某些时候(手机浏览器)          没有任何反应只是停留在同一页上...........(正常)

errors: Cannot redirect after HTTP headers have been sent arises some times(mobile browsers) nothing happens just stays on the same page ...........(normal)

更过我试图在firbug调试在那里调用后做出我收到的过程

more over i tried to debug in firbug in there after the call made i am getting the process

www.test.com是什么,但我的本地主机和端口号 POST http://www.test.com/forms/submit 这是正确的道路来传递数据 GET http://www.test.com/mobile/home?success=true我要重定向到其继续显示加载符号不从那里再动火灾错误的道路。

www.test.com is nothing but my localhost and its port number POST http://www.test.com/forms/submit which is right path to pass data GET http://www.test.com/mobile/home?success=true the path i have to redirect to its keep showing loading sign doesn't move further from there in fire bug..

我怀疑正在取得请求而不是重定向。任何一个可以解决这个问题了,或 任何变通嘿,如果是一些其他的问题...........感谢.....

i suspect that request is being made but not redirecting . can any one fix this out or any work around plz, if it is some other problem...........thanks.....

推荐答案

该错误无法重定向HTTP标头已被送往后意味着你已经开始返回HTTP响应到客户端。因此,你现在不能重定向。前面看在你的控制器方法,看它是否返回任何客户端和移动重定向检测早期的。

The error "Cannot redirect after HTTP headers have been sent" means that you've already started returning the HTTP response to the client. Therefore you can't redirect it now. Look earlier in your controller method to see if it returns anything to the client and move the redirect check earlier.

这看起来很奇怪的唯一的另一件事是,你必须在视图控制器之前(默认为/ {控制器} / {查看}),但也许你的路由设置了这种方式。

The only other thing that looks odd is that you have the view before the controller (default is /{controller}/{view}), but perhaps your routes are set up that way.

 
精彩推荐