开发者

How do you Response.Redirect to another website with the same name, but with different port?

I have two separate websites running locally on my IIS server at work. One is on normal port 80 and the other 90. Now, I have a Default page which makes the users select one of the pictures that will redirect them to the correct website.

It works fine with the port 80, since you don't have to specify which port you are running a normal website, but how can I redirect the second picture to redirect to port 90.

This is the code I have, but it keeps adding a stupid forward slash...

Response.Redirect(Request.ApplicationPath + ":90/login.aspx");

It ends up showing http://192.168.2.122/:90/login.aspx.

Any help will be gladl开发者_C百科y appreciated. Thanks!


Response.Redirect(Request.ApplicationPath.TrimEnd("/") + ":90/login.aspx");


You can use Request.Url to fetch segments of the current URL.

Response.Redirect(
  "http://" + Request.Url.Host + ":90" + 
  Request.ApplicationPath + "/login.aspx");

Edit: tweaked to compensate for alternate Application paths (since I did bring it up in a comment).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜