问题描述
环境:用户当前在以下页面:
Context: User is currently in the following page: http://myinternaldomain.com/page/
问题:
当用户点击上面网页上的按钮,处理这个点击应该做一些处理,用户重定向到一个外部域控制器的MVC方法说google.com。我想下面分别对2陈述,但两者调用的外部URL附加到当前内部页面,用户是:
Issue:When user clicks on a button in the above page, the MVC Controller method that handles this click should do some processing and redirect the user to an external domain say google.com. I tried the 2 statements below separately but both calls append the external url to the current internal page that the user is on:
System.Web.HttpContext.Current.Response.Redirect("www.google.com"); // plain old HttpResponse object
return Controller.Response.Redirect("www.google.com"); // MVC Controller's response object
以上两种语句导致用户使用重定向到:
http://myinternaldomain.com/page/www.google.com
而不是仅仅将用户重定向到www.google.com。
Both of the above statements result in user getting redirected to: http://myinternaldomain.com/page/www.google.cominstead of just redirecting the user to www.google.com.
我是什么在这里失踪?
推荐答案
您需要preFIX你的URL的http://,像这样的:
You need to prefix your URL with "http://", like this:
Controller.Response.Redirect("http://www.google.com");
这篇关于为什么Response.Redirect的不定向外部URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!