-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support C# Async Constructs During Page Rendering (#3984)
* Use IPortalSettings in Localization APIs This is in preparation to move the Localization.SetThreadCultures call to an HttpModule. * Move Localization.SetThreadCultures to HttpModule This is in support of turning on Async for Default.aspx. Per a discussion with the ASP.NET team, setting the thread culture in OnInit for a page does not persist in the context for the page (once Async is turned on an there are multiple contexts to consider). Setting it from an IHttpModule implementation, however, will persist throughout that request. This fixes the bug that plagued #2089, where, as an example, URLs would be generated for the incorrect language once Async was on. * Add Async support to Default.aspx This is a second try for 0cf1b13 #2089. This will allow for async calls from WebForms controls (preferably via calling RegisterAsyncTask, see https://docs.microsoft.com/en-us/aspnet/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45#registerasynctask-notes)
- Loading branch information
Showing
10 changed files
with
122 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
DNN Platform/HttpModules/Localization/LocalizationModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
namespace DotNetNuke.HttpModules.Localization | ||
{ | ||
using System; | ||
using System.Web; | ||
|
||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.Services.Localization; | ||
|
||
/// <summary>Sets up localization for all requests.</summary> | ||
public class LocalizationModule : IHttpModule | ||
{ | ||
/// <inheritdoc /> | ||
public void Init(HttpApplication context) | ||
{ | ||
context.BeginRequest += Context_BeginRequest; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
// intentionally left empty | ||
} | ||
|
||
private static void Context_BeginRequest(object sender, EventArgs e) | ||
{ | ||
var isInstallPage = HttpContext.Current.Request.Url.LocalPath.ToLowerInvariant().Contains("installwizard.aspx"); | ||
if (isInstallPage) | ||
{ | ||
return; | ||
} | ||
|
||
var portalSettings = PortalController.Instance.GetCurrentSettings(); | ||
Localization.SetThreadCultures(Localization.GetPageLocale(portalSettings), portalSettings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<configuration> | ||
<nodes configfile="web.config"> | ||
<node path="/configuration/system.webServer/modules" action="update" key="name" collision="overwrite"> | ||
<add name="Localization" type="DotNetNuke.HttpModules.Localization.LocalizationModule, DotNetNuke.HttpModules" preCondition="managedHandler" /> | ||
</node> | ||
</nodes> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters