I have tried to get host name from OWIN Startup class by using below code in ASP.NET web forms. I am getting http://127.0.0.1 host name instead of http://localhsot:portnumber. Also I am not able to get real host name i.e., www.testsite.com. Is there any options available to get actual host name from OWIN Startup class?
[assembly: OwinStartup(typeof(Startup))]
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(10),
SlidingExpiration = true
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
var host = HttpContext.Current.Request.Url.Host.ToString().ToLower(); <-- I am getting http://127.0.0.1 instead of http://localhsot:portnumber.
var queryString = "";
if (host.Contains("technicolor"))
{
queryString = "1";
}
else if (host.Contains("3") || HttpContext.Current.Request.IsLocal)
{
queryString = "2";
}
else {
queryString = "3"
}
var options = new PingAuthenticationOptions(
pingAuthenticationUrl: ConfigurationManager.AppSettings["Ping::LoginUrl"] + ACSIdx,
pingLogoutUrl: ConfigurationManager.AppSettings["Ping::LogoutUrl"],
certificateFile: certificate,
pingResponseDestination: ConfigurationManager.AppSettings["Ping::DestinationUrl"],
externalLoginCallback: ConfigurationManager.AppSettings["Ping::ExternalLoginCallback"],
samlProcessor: new SamlProcessor());
app.UsePingAuthentication(options);
}
}