-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default Visual Studio project appsettings.json not allowing the configuration of server.urls #1915
Comments
For starters, "server.urls" is obsolete, it's just "urls" now. Can you show your Program.Main code? You need to read config in Program.Main add assign it to WebHostBuilder if you want it to read hosting settings. The config in Startup is not applied to WebHostBuilder. |
I am aware of this but I see it as a bug in one or more of documentation, template or framework. The fact you mention was not particularly clear to me from the documentation. Reading it with that understanding now, I see how it was intended that way, but is not at all the way I understood it because of the flow of examples, how they were referenced and the vague nature of how that fact was explained. Additionally, if that is how it is intended, I would think the default template should have a config that adds the environment variables and a hosting.json to the web builder. As is, I am left asking why there is an adding of environment variables to config in startup in the template if it doesn't apply to the web host builder. Even better IMO would be to apply the config in startup to the hosting settings. This is primarily for the reason that you have the environment there as part of the IHostingEnvironment. You don't have that in Program.Main without going through additional code to pull it out of an environment variable. The other reason is it would seem to reduce a lot of duplicate code in terms of needing to specify configurations in multiple places for hosting and for other settings. The Program.Main is whatever the default web API template has. If memory serves it should be: var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run(); |
This issue is being closed because it has not been updated in 3 months. We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate. |
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a temporary error. The following address(es) deferred:
spinthemoose@gmail.com
Domain spinthemoose.com has exceeded the max emails per hour (232/200 (115%)) allowed. Message will be reattempted later
…------- This is a copy of the message, including all the headers. ------
Received: from github-smtp2-ext8.iad.github.net ([192.30.252.199]:44869 helo=github-smtp2a-ext-cp1-prd.iad.github.net)
by cp1164.blacksun.ca with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.89_1)
(envelope-from <noreply@github.com>)
id 1eVQiW-0000Sf-3z
for david@spinthemoose.com; Sat, 30 Dec 2017 17:39:04 -0600
Date: Sat, 30 Dec 2017 15:38:44 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com;
s=pf2014; t=1514677124;
bh=xyCd3kLy1PcOLFVb41TUaRXOZJtijRfb9U2oXcL10KY=;
h=From:Reply-To:To:Cc:In-Reply-To:References:Subject:List-ID:
List-Archive:List-Post:List-Unsubscribe:From;
b=fqON4/5zB6OXSA9pX3wDO+JpMaJIzS8k9Kks94wFwjOY8F41elp88+3iWqdf9oI6O
+WXvUXF3HA1LvKS4xqvkz+TazQFIID3khqv4V/TidjfX03+JXkUKwLcxOgptE1+52F
g+e1y6N9qZ/f69AN0IIbhCbFvPuoy0VBzbAj6Iuo=
From: "ASP.NET Hello Bot" <notifications@github.com>
Reply-To: aspnet/Home <reply@reply.github.com>
To: aspnet/Home <Home@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Message-ID: <aspnet/Home/issues/1915/354575037@github.com>
In-Reply-To: <aspnet/Home/issues/1915@github.com>
References: <aspnet/Home/issues/1915@github.com>
Subject: Re: [aspnet/Home] Default Visual Studio project appsettings.json not
allowing the configuration of server.urls (#1915)
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5a4823843f19d_a2d3fa16355ef301955e7";
charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: list
X-GitHub-Sender: aspnet-hello
X-GitHub-Recipient: davidalpert
X-GitHub-Reason: subscribed
List-ID: aspnet/Home <Home.aspnet.github.com>
List-Archive: https://github.com/aspnet/Home
List-Post: <mailto:reply@reply.github.com>
List-Unsubscribe: <mailto:unsub+0000a9445fffd47c3c6d95d95beb83b9e728fa5a33c1d7e792cf00000001165fe58492a169ce0c2579b1@reply.github.com>,
<https://github.com/notifications/unsubscribe/AACpRA6h15TttHza6HbKozIiCxt_KPnXks5tFsmEgaJpZM4LwZYj>
X-Auto-Response-Suppress: All
X-GitHub-Recipient-Address: david@spinthemoose.com
----==_mimepart_5a4823843f19d_a2d3fa16355ef301955e7
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
This issue is being closed because it has not been updated in 3 months.
We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#1915 (comment)
----==_mimepart_5a4823843f19d_a2d3fa16355ef301955e7
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p>This issue is being closed because it has not been updated in 3 months=
.</p>
<p>We apologize if this causes any inconvenience. We ask that if you are =
still encountering this issue, please log a new issue with updated inform=
ation and we will investigate.</p>
<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&m=
dash;<br />You are receiving this because you are subscribed to this thre=
ad.<br />Reply to this email directly, <a href=3D"https://github.com/aspn=
et/Home/issues/1915#issuecomment-354575037">view it on GitHub</a>, or <a =
href=3D"https://github.com/notifications/unsubscribe-auth/AACpRPAA67ZgBs1=
B_Ly2jktYNHm_lstaks5tFsmEgaJpZM4LwZYj">mute the thread</a>.<img alt=3D"" =
height=3D"1" src=3D"https://github.com/notifications/beacon/AACpRBAiltLna=
HdOBkbpwMJHQWsAdGAxks5tFsmEgaJpZM4LwZYj.gif" width=3D"1" /></p>
<div itemscope itemtype=3D"http://schema.org/EmailMessage">
<div itemprop=3D"action" itemscope itemtype=3D"http://schema.org/ViewActi=
on">
<link itemprop=3D"url" href=3D"#19
15#issuecomment-354575037"></link>
<meta itemprop=3D"name" content=3D"View Issue"></meta>
</div>
<meta itemprop=3D"description" content=3D"View this Issue on GitHub"></me=
ta>
</div>
<script type=3D"application/json" data-scope=3D"inboxmarkup">{"api_versio=
n":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name"=
:"GitHub"},"entity":{"external_key":"github/aspnet/Home","title":"aspnet/=
Home","subtitle":"GitHub repository","main_image_url":"https://cloud.gith=
ubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c=
7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/=
143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name=
":"Open in GitHub","url":"https://github.com/aspnet/Home"}},"updates":{"s=
nippets":[{"icon":"PERSON","message":"@aspnet-hello in #1915: This issue =
is being closed because it has not been updated in 3 months.\r\n\r\nWe ap=
ologize if this causes any inconvenience. We ask that if you are still en=
countering this issue, please log a new issue with updated information an=
d we will investigate.\r\n"}],"action":{"name":"View Issue","url":"https:=
//github.com/aspnet/Home/issues/1915#issuecomment-354575037"}}}</script>=
----==_mimepart_5a4823843f19d_a2d3fa16355ef301955e7--
|
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a temporary error. The following address(es) deferred:
spinthemoose@gmail.com
Domain spinthemoose.com has exceeded the max emails per hour (233/200 (116%)) allowed. Message will be reattempted later
…------- This is a copy of the message, including all the headers. ------
Received: from o6.sgmail.github.com ([192.254.113.101]:32286)
by cp1164.blacksun.ca with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
(Exim 4.89_1)
(envelope-from <bounces+848413-6f87-david=spinthemoose.com@sgmail.github.com>)
id 1eVQiX-0000Si-1U
for david@spinthemoose.com; Sat, 30 Dec 2017 17:39:05 -0600
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=github.com;
h=from:reply-to:to:cc:in-reply-to:references:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe;
s=s20150108; bh=xvG/43rvVkaJqXz4IR/uEiP1oxw=; b=iAlAeBR6z7fNd/G+
ryDmlIhbzEK9Sujq6TI52D1HQ8pE7l2zFtd4/3EuEoULIbB/jVU5riwqOisdli9q
iKezqE2bx0lZYKXlCbX6FyuNmQDbrtLXtVt2fRKQSYixcXc+RiSLt13jWGknOLPj
tLzL9Xe1IOY3oAnXGTe1+UYd2ug=
Received: by filter0810p1mdw1.sendgrid.net with SMTP id filter0810p1mdw1-5138-5A482384-B
2017-12-30 23:38:44.70789055 +0000 UTC
Received: from github-smtp2b-ext-cp1-prd.iad.github.net (github-smtp2b-ext-cp1-prd.iad.github.net [192.30.253.17])
by ismtpd0024p1iad2.sendgrid.net (SG) with ESMTP id 8ZsdbuuxRxS3plTNuqwFyw
for <david@spinthemoose.com>; Sat, 30 Dec 2017 23:38:44.696 +0000 (UTC)
Date: Sat, 30 Dec 2017 23:38:44 +0000 (UTC)
From: "ASP.NET Hello Bot" <notifications@github.com>
Reply-To: aspnet/Home <reply@reply.github.com>
To: aspnet/Home <Home@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Message-ID: <aspnet/Home/issue/1915/issue_event/1405208615@github.com>
In-Reply-To: <aspnet/Home/issues/1915@github.com>
References: <aspnet/Home/issues/1915@github.com>
Subject: Re: [aspnet/Home] Default Visual Studio project appsettings.json not
allowing the configuration of server.urls (#1915)
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5a48238489bfb_28bcc3f967d01cf2c2133610";
charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: list
X-GitHub-Sender: aspnet-hello
X-GitHub-Recipient: davidalpert
X-GitHub-Reason: subscribed
List-ID: aspnet/Home <Home.aspnet.github.com>
List-Archive: https://github.com/aspnet/Home
List-Post: <mailto:reply@reply.github.com>
List-Unsubscribe: <mailto:unsub+0000a9445fffd47c3c6d95d95beb83b9e728fa5a33c1d7e792cf00000001165fe58492a169ce0c2579b1@reply.github.com>,
<https://github.com/notifications/unsubscribe/AACpRA6h15TttHza6HbKozIiCxt_KPnXks5tFsmEgaJpZM4LwZYj>
X-Auto-Response-Suppress: All
X-GitHub-Recipient-Address: david@spinthemoose.com
X-SG-EID: rlj3t9ahcX0BZUzAOlajQ3VmBXo43xFJc4M1ImIDJhGm3AxYxdCEDxlpYtOQYuNHU0Rrtxv4wyav50
GCZ1cyoy/rmEts9wRR0KmDyHmegPonRLNWjdjAQ2SEmg1cXX7RKugiG/BOjatjZ6hwgkIIgZOobn3i
QVMLG1ghqNHOJDSpDUsB+Ow9uFi2KVwR+bRba7MkdYgzQ/CWFq6CLqdG7y3E6E3BcdhXus6gZfOtQg
E=
----==_mimepart_5a48238489bfb_28bcc3f967d01cf2c2133610
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Closed #1915.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#1915 (comment)
----==_mimepart_5a48238489bfb_28bcc3f967d01cf2c2133610
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Closed <a href="#1915" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="203782577" data-permission-text="Issue title is private" data-url="#1915>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="#1915 (comment) it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AACpRPAA67ZgBs1B_Ly2jktYNHm_lstaks5tFsmEgaJpZM4LwZYj">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AACpRBAiltLnaHdOBkbpwMJHQWsAdGAxks5tFsmEgaJpZM4LwZYj.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="#1915 (comment)>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/aspnet/Home","title":"aspnet/Home","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/aspnet/Home"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Closed #1915."}],"action":{"name":"View Issue","url":"#1915 (comment)>
----==_mimepart_5a48238489bfb_28bcc3f967d01cf2c2133610--
|
OK I figured out what was wrong. ConfigureAppConfiguration doesn't affect config used during app startup. It is used later. |
Default Visual Studio project appsettings.json not allowing the configuration of server.urls
The functional impact of this is that applications that are hosted independently of IIS or tested in that context, require a separate additional configuration file must be added to the default web api project created in Visual Studio
In order to encounter this issue use visual studio 2015 and .net core 1.0.1 tools preview 2 and do the following:
Create a new ASP.NET core web application. (This can either target .net framework 4.6.1 or .net core as I tested both at one point but only verified these steps against the asp.net webapi project that targets the core)
Use the webapi sub-template.
Add: ","server.urls": "http://*:5005"" without the final open and closing double quotes before the final bracket of appsettings.json.
Start the application debugging in the non IIS option for starting and debugging.
Observer that the application binds to port 5000 rather than the specified port 5005
I would expect the default json configuration to allow the setting of server.urls and bind to port 5005.
In actuality, the server.urls parameter in the default appsettings.json is being ignored and the app is starting up listening on port 5000
The problem seems to be in WebHostBuilder.UseStartup. If I add a separate file hosting.json to the program.cs then it loads the parameter correctly and binds to the specified port. The reason I say this is that the same file specified via a configuration builder and added via WebHostBuilder.UseConfiguration properly loads the file and binds to the specified port 5005.
The text was updated successfully, but these errors were encountered: