Add environment variables for external information #46
Comments
Adding here for workaround reference with PS, a prototype ...
Setting the execution policy didn't work, so I had to elevate the AppPool's user identity to PowerShell bits for Core is still alpha (as of 11/27/2016), and I ended up with dep conflicts in my 1.1/MSBuild test app ( NuGet.config: csproj:
|
@Drawaes Looks like you are just using Microsoft.Web.Administration get your site bindings. This is still possible in .NET Core. See https://www.nuget.org/packages/Microsoft.Web.Administration/10.0.0-rc1 If you can provide some more detailed information about what you are doing, we may be able to help you. |
sooooooo much nicer ... ServerManager serverManager = new ServerManager();
ViewBag.PORT = serverManager.Sites["testselfcontained"].Bindings[0].EndPoint.Port.ToString(); Just had to run it under |
I will give that a crack |
Feel free to re-open if that doesn't work out for you |
That's good enough for me. Thanks |
Is it possible to add environment variables to allow the hosted application to understand the external address that IIS is exposing for the hosted application. This information is available from the HttpContext.Request but only once you have a request. An example of how you can do this in a "traditional asp.net" application
ServerManager serverMgr = new ServerManager();
Site site = serverMgr.Sites["YourSiteName"];
List<string[]> urls = new List<string[]>();
foreach (Binding binding in site.Bindings)
{
string bindingInfo = binding.BindingInformation;
string subString = bindingInfo.Substring(2, bindingInfo.Length - 2);
string[] adrs = subString.Split(':');
adrs[0] = "localhost:" + adrs[0];
urls.Add(adrs);
}
The text was updated successfully, but these errors were encountered: