vendredi 28 février 2020

How to read the IISExpressSSLPort dynamically in Visual Studio

Quick question, hopefully a simply answer. When working with a Web Project in Visual Studios, if I enable SSL, it generates an SSL URL.

The problem I'm having is that when I run the application (debugging), it wants to start using http on whatever port that is. So my fix is to basically ..

if (HttpContext.Request.IsLocal == true)
{
   myUriBuilder.Scheme = Uri.UriSchemeHttps;
   myUriBuilder.Port = 44331;
}

I would very much like to be able to dynamically determine what that SSL port is for this project without having to hard code it (code re-usability)

I know that port is located in the .csproj file under the node IISExpressSSLPort, but short of trying to parse up the file, I thought I'd reach out and see if someone knows a way to grab that value in code at runtime.





Aucun commentaire:

Enregistrer un commentaire