为什么Response.Redirect不重定向外部URL?

cra*_*rse 7 c# asp.net redirect

上下文:用户当前位于以下页面:http://myinternaldomain.com/page/

问题:当用户单击上一页中的按钮时,处理此点击的MVC Controller方法应该进行一些处理并将用户重定向到外部域,例如google.com.我分别尝试了下面的两个语句,但两个调用都将外部URL附加到用户所在的当前内部页面:

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
Run Code Online (Sandbox Code Playgroud)

上述两个声明都会导致用户重定向到:http: //myinternaldomain.com/page/www.google.com, 而不是仅将用户重定向到www.google.com.

我在这里错过了什么?

Tim*_*nes 12

您需要在URL前加上"http://",如下所示:

Controller.Response.Redirect("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)