Skip to content

Commit f96c6be

Browse files
committed
Merge remote-tracking branch 'origin/v9/dev' into v9/dev
2 parents 4a1820b + 138ef42 commit f96c6be

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

build/templates/UmbracoProject/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"NoNodesViewPath":{
3333
"longName": "no-nodes-view-path",
3434
"shortName": ""
35+
},
36+
"UseHttpsRedirect": {
37+
"longName": "use-https-redirect",
38+
"shortName": ""
3539
}
3640
},
3741
"usageExamples": [

build/templates/UmbracoProject/.template.config/ide.host.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
"text": "Optional: Path to a custom view presented with the Umbraco installation contains no published content"
6363
},
6464
"isVisible": "true"
65+
},
66+
{
67+
"id": "UseHttpsRedirect",
68+
"name": {
69+
"text": "Optional: Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting."
70+
},
71+
"isVisible": "true"
6572
}
6673
]
6774
}

build/templates/UmbracoProject/.template.config/template.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@
293293
"UsingUnattenedInstall":{
294294
"type": "computed",
295295
"value": "(FriendlyName != \"\" && Email != \"\" && Password != \"\" && ConnectionString != \"\")"
296+
},
297+
"UseHttpsRedirect":{
298+
"type": "parameter",
299+
"datatype":"bool",
300+
"defaultValue": "false",
301+
"description": "Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting (Default: false)"
296302
}
297303
}
298304
}

build/templates/UmbracoProject/appsettings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
},
1616
"Umbraco": {
1717
"CMS": {
18-
//#if (HasNoNodesViewPath)
18+
//#if (HasNoNodesViewPath || UseHttpsRedirect)
1919
"Global": {
20+
//#if (!HasNoNodesViewPath && UseHttpsRedirect)
21+
"UseHttps": true
22+
//#elseif (UseHttpsRedirect)
23+
"UseHttps": true,
24+
//#endif
25+
//#if (HasNoNodesViewPath)
2026
"NoNodesViewPath": "NO_NODES_VIEW_PATH_FROM_TEMPLATE"
27+
//#endif
2128
},
2229
//#endif
2330
"Hosting": {

src/Umbraco.Web.UI/Startup.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public class Startup
1515
private readonly IConfiguration _config;
1616

1717
/// <summary>
18-
/// Initializes a new instance of the <see cref="Startup"/> class.
18+
/// Initializes a new instance of the <see cref="Startup" /> class.
1919
/// </summary>
20-
/// <param name="webHostEnvironment">The Web Host Environment</param>
21-
/// <param name="config">The Configuration</param>
20+
/// <param name="webHostEnvironment">The web hosting environment.</param>
21+
/// <param name="config">The configuration.</param>
2222
/// <remarks>
2323
/// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337
2424
/// </remarks>
@@ -28,11 +28,10 @@ public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config)
2828
_config = config ?? throw new ArgumentNullException(nameof(config));
2929
}
3030

31-
32-
3331
/// <summary>
34-
/// Configures the services
32+
/// Configures the services.
3533
/// </summary>
34+
/// <param name="services">The services.</param>
3635
/// <remarks>
3736
/// This method gets called by the runtime. Use this method to add services to the container.
3837
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
@@ -50,15 +49,21 @@ public void ConfigureServices(IServiceCollection services)
5049
}
5150

5251
/// <summary>
53-
/// Configures the application
52+
/// Configures the application.
5453
/// </summary>
54+
/// <param name="app">The application builder.</param>
55+
/// <param name="env">The web hosting environment.</param>
5556
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5657
{
5758
if (env.IsDevelopment())
5859
{
5960
app.UseDeveloperExceptionPage();
6061
}
6162

63+
#if (UseHttpsRedirect)
64+
app.UseHttpsRedirection();
65+
66+
#endif
6267
app.UseUmbraco()
6368
.WithMiddleware(u =>
6469
{

0 commit comments

Comments
 (0)