I had Ajax call which will call an action called "submit" on form submission in a controller.. in that i got something like below....
我有一个Ajax调用,它将在控制器中的表单提交上调用一个名为“submit”的动作..因为我得到了类似下面的内容....
if (CSConfigurationMgr.IsMobileUrl(Request.UrlReferrer.AbsoluteUri.PathFromURL())) return RedirectToAction("home", "mobile", new { success = true});
if(CSConfigurationMgr.IsMobileUrl(Request.UrlReferrer.AbsoluteUri.PathFromURL()))返回RedirectToAction(“home”,“mobile”,new {success = true});
what it will do is redirects to hompage and have to display thankyou message...
它会做什么重定向到hompage并且必须显示thankyou消息...
i tried just giving url as xxxxxxx/mobile/home?success=true it worked as i expect..
我试着给url作为xxxxxxx / mobile / home?success = true它按照我的预期工作..
i am getting true for that condition and going to return statement but i am not redirect to the new page ......
我对这个条件变得真实并且要返回声明,但我没有重定向到新页面......
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 .....
我已检查路线没有问题,我已经检查通过将redirecttoaction置于其他一些动作,它工作正常我被重定向到新的页面。但它在这里不起作用.....
errors: Cannot redirect after HTTP headers have been sent arises some times(mobile browsers) nothing happens just stays on the same page ...........(normal)
错误:HTTP标头发送后无法重定向(移动浏览器)没有任何反应只是停留在同一页面...........(正常)
more over i tried to debug in firbug in there after the call made i am getting the process
更多的事情,我试图在电话调试后调试,我打电话给我
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..
www.test.com只是我的本地主机及其端口号POST http://www.test.com/forms/submit这是通过数据的正确途径GET http://www.test.com/mobile/home? success = true我必须重定向到它继续显示加载标志的路径不会从火灾中进一步移动..
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.....
我怀疑正在提出请求,但没有重定向。可以任何人解决这个或任何工作围绕PLZ,如果它是一些其他问题...........谢谢.....
1 个解决方案
#1
1
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.
错误“在发送HTTP标头后无法重定向”意味着您已经开始将HTTP响应返回给客户端。因此,您现在无法重定向它。先在控制器方法中查看它是否向客户端返回任何内容并提前移动重定向检查。
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.
唯一看起来奇怪的是你在控制器之前有视图(默认是/ {controller} / {view}),但也许你的路由是这样设置的。
#1
1
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.
错误“在发送HTTP标头后无法重定向”意味着您已经开始将HTTP响应返回给客户端。因此,您现在无法重定向它。先在控制器方法中查看它是否向客户端返回任何内容并提前移动重定向检查。
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.
唯一看起来奇怪的是你在控制器之前有视图(默认是/ {controller} / {view}),但也许你的路由是这样设置的。