I was pairing with Remco (start a blog man!) today and we came across an interesting assumption. The code we were looking at created a redirect URL using the following code.
return Redirect("http://" + Request.Url.Host + "/" + url.Trim('/'));
'Host' returns the "host component of this instance". No bad thing, until you start to test on a server using a port other than port 80. Your code may well break because the URL you are constructing doesn't contain the port number that your Web application is running on. To fix this you can use Request.Url.Authority. 'Authority' return the "DNS host name or IP address and the port number for a server".
No comments:
Post a Comment