Why doesn't Response.Redirect redirect an external URL?

Context: The user is currently located on the following page: http://myinternaldomain.com/page/

Question: When a user clicks a button on the above page, the MVC Controller method that handles this click must do some processing and redirect the user to an external domain, say google.com. I tried the two statements below separately, but both calls add an external url to the current internal page on which the user is enabled:

System.Web.HttpContext.Current.Response.Redirect("www.google.com"); // plain old HttpResponse object return Controller.Response.Redirect("www.google.com"); // MVC Controller response object 

Both of these statements lead to redirecting the user to: http://myinternaldomain.com/page/www.google.com and not just redirecting the user to www.google.com.

What am I missing here?

+6
source share
1 answer

You need to specify your URL using "http: //", for example:

 Controller.Response.Redirect("http://www.google.com"); 
+11
source

Source: https://habr.com/ru/post/895655/


All Articles