Get original url without non-standard port (C#)

前端 未结 6 887
执念已碎
执念已碎 2021-02-12 21:43

First question!


Environment

MVC, C#, AppHarbor.

Problem

I am calling an openid provider,

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-12 21:48

    Something like

    String port = Request.ServerVariables["SERVER_PORT"] == "80" ? "" : ":" + Request.ServerVariables["SERVER_PORT"];
    String virtualRoot = Url.Content("~/");
    destinationUrl = String.Format("http://{0}{1}{2}", Request.ServerVariables["SERVER_NAME"], port + virtualRoot, "/callback");
    

提交回复
热议问题