Ticket T1186787
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Blazor - Obtain request information from HttpContext (query string parameter) for auto login from URL

NavigationManager BaseUrl Not found

created 2 years ago (modified 2 years ago)

Hi Y'all,

I have created a blazor XAF application, which based on the url goes to a different database connection (connectionstring).

I Created a small service for this:

C#
public class MyService : IMyService { public readonly NavigationManager _navigationManager; public MyService(NavigationManager navigationManager) { this._navigationManager = navigationManager; } public string FindConnectionString() { string connectionstring = string.Empty; var url = _navigationManager.BaseUri; //do stuff with url and returns connectionstring return connectionstring; } } public interface IMyService { string FindConnectionString(); }

In Startup.cs I have:

C#
services.AddScoped<IMyService, MyService>();

Which will be called in the XAF Builder:

C#
builder.ObjectSpaceProviders .AddSecuredXpo((serviceProvider, options) => { var myservice = serviceProvider.GetRequiredService<IMyService>(); var connectionString = myservice.FindConnectionString(); ArgumentNullException.ThrowIfNull(connectionString); options.ConnectionString = connectionString; options.ThreadSafe = true; options.UseSharedDataStoreProvider = true; }) .AddNonPersistent();

This worked Fine in 22.1.5 but I upgraded my application to 23.1.4 and now the NavigationManager is not connected to JS anymore.

Show previous comments (2)
Dennis Garavsky (DevExpress) 2 years ago

    Hello, Michael.

    When I target Devexpress lib's 22.1.5 MyService works fine, If I change this to 23.1.4 It goes in, works fine, after that i goes back in there (seems like it is an underlaying redirect, because it get's back in the constructor)

    I am afraid correlation does not imply causation ("after" does not automatically mean "because of") - at least our developers are unaware of product changes that might affect this. So, my previous recommendation still applies. If you received any .NET or JS errors in the latest versions, search public community resources for these errors as well.

    Probably, your current approach did not work reliably even in older versions, and a different or more robust approach should be used. While we have not experienced exactly the same task before (with a connection string based on URL), we used the following approach in our E1344 example: https://github.com/DevExpress-Examples/XAF_how-to-change-connection-to-the-database-at-runtime-e1344/blob/3b0719ad2926cfedc23a6deb7489d56dbbd8fdd0/CS/XPO/ASP.NETCore/Blazor/RuntimeDbChooser.Blazor.Server/Startup.cs#L50 - note that IConnectionStringProvider is used more than in one place here (for instance, also to control BlazorApplication.IsCompatibilityChecked).

    M M
    Michael de Vlieger 2 years ago

      Hi Dennis,

      I Cannot find anything about a change between DevExpress 22.1.5 and 23.1.4 in public community resources.

      However I did some investigations by myself. It seems like the changes happen between 22.1.11 and 22.2.3

      As this is the only change which breaks the applications (I did not change anything else at all) there should be a correlation. As the behaviour is different.

      M M
      Michael de Vlieger 2 years ago

        I went further in my investigation.

        It seems to be even weirder then expected.

        When I execute my application I added a breakpoint in MyService on the line where states:

        C#
        var url = _navigationManager.BaseUri;

        In 22.1.5 it hits only once.

        In 22.2.3 it hits twice. With different call stacks.

        The first one (right one, also hitting 22.1.5)

        Call Stack
        Profix.WMS.Blazor.Server.dll!Profix.WMS.Blazor.Server.Services.MyService.FindConnectionString() Line 32 C# Profix.WMS.Blazor.Server.dll!Profix.WMS.Blazor.Server.Startup.ConfigureServices.AnonymousMethod__4_5(System.IServiceProvider serviceProvider, DevExpress.ExpressApp.ApplicationBuilder.XPObjectSpaceProviderOptions options) Line 59 C# DevExpress.ExpressApp.Security.Xpo.v22.2.dll!DevExpress.ExpressApp.ApplicationBuilder.SecuredObjectSpaceProviderBuilderExtensions.AddSecuredXpo.AnonymousMethod__0(System.IServiceProvider serviceProvider) Line 69 C# DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.ApplicationBuilder.Internal.ObjectSpaceProviderFactoryForApplicationBuilder.CreateObjectSpaceProviders() Line 118 C# System.Private.CoreLib.dll!System.Collections.Generic.List<DevExpress.ExpressApp.IObjectSpaceProvider>.InsertRange(int index, System.Collections.Generic.IEnumerable<DevExpress.ExpressApp.IObjectSpaceProvider> collection) Unknown DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.XafApplication.CreateObjectSpaceProviders(string connectionString) Line 344 C# DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.XafApplication.Setup() Line 1683 C# DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Services.XafApplicationProvider.CreateApplication() Line 84 C# System.Private.CoreLib.dll!System.Lazy<DevExpress.ExpressApp.Blazor.BlazorApplication>.ViaFactory(System.Threading.LazyThreadSafetyMode mode) Unknown System.Private.CoreLib.dll!System.Lazy<DevExpress.ExpressApp.Blazor.BlazorApplication>.ExecutionAndPublication(System.LazyHelper executionAndPublication, bool useDefaultConstructor) Unknown System.Private.CoreLib.dll!System.Lazy<DevExpress.ExpressApp.Blazor.BlazorApplication>.CreateValue() Unknown DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Pages.LoginPageBase.CreateControl() Line 59 C# DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Pages.LoginPage.BuildRenderTree.AnonymousMethod__0_0(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder2) Line 13 C# DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Components.XafExceptionHandler.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) Line 6 C# ....

        And then the failing one:

        Call Stack
        Profix.WMS.Blazor.Server.dll!Profix.WMS.Blazor.Server.Services.MyService.FindConnectionString() Line 58 Profix.WMS.Blazor.Server.dll!Profix.WMS.Blazor.Server.Startup.ConfigureServices.AnonymousMethod__4_5(System.IServiceProvider serviceProvider, DevExpress.ExpressApp.ApplicationBuilder.XPObjectSpaceProviderOptions options) Line 59 DevExpress.ExpressApp.Security.Xpo.v22.2.dll!DevExpress.ExpressApp.ApplicationBuilder.SecuredObjectSpaceProviderBuilderExtensions.AddSecuredXpo.AnonymousMethod__0(System.IServiceProvider serviceProvider) Line 69 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.ApplicationBuilder.Internal.ObjectSpaceProviderFactoryForApplicationBuilder.CreateObjectSpaceProviders() Line 118 System.Private.CoreLib.dll!System.Collections.Generic.List<DevExpress.ExpressApp.IObjectSpaceProvider>.InsertRange(int index, System.Collections.Generic.IEnumerable<DevExpress.ExpressApp.IObjectSpaceProvider> collection) Unknown DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.XafApplication.CreateObjectSpaceProviders(string connectionString) Line 344 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.XafApplication.Setup() Line 1683 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationCreator.CreateSharedApplication.AnonymousMethod__0() Line 92 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.Blazor.AmbientContext.ValueManagerStorageContext.DevExpress.ExpressApp.Blazor.AmbientContext.IValueManagerStorageContext.RunWithStorage.AnonymousMethod__0() Line 69 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.Blazor.AmbientContext.ValueManagerContext.IsolatedContext<DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer>(System.Func<DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer> function) Line 98 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.Blazor.AmbientContext.ValueManagerContext.RunIsolated<DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer>(System.Func<DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer> function) Line 93 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationProvider.GetSharedApplicationContainer.AnonymousMethod__4_0(string _) Line 73 System.Collections.Concurrent.dll!System.Collections.Concurrent.ConcurrentDictionary<string, DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer>.GetOrAdd(string key, System.Func<string, DevExpress.ExpressApp.AspNetCore.Shared.SharedApplicationContainer> valueFactory) Unknown DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Services.Localization.SharedCaptionHelperProvider.SharedCaptionHelperAspNetCore.GetModelApplication() Line 78 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Validation.Internal.RuleSetInitializer.InitializeRuleSet(DevExpress.Persistent.Validation.RuleSet ruleSet) Line 111 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Validation.Internal.RuleSetService.CreateRuleSet() Line 82 DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.AspNetCore.Validation.Internal.RuleSetService.RuleSet.get() Line 65 DevExpress.ExpressApp.Validation.v22.2.dll!DevExpress.ExpressApp.Validation.ResultsHighlightController.OnActivated() Line 86 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.Utils.BoolList.EndUpdate() Line 181 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.ViewController.SetView(DevExpress.ExpressApp.View newView) Line 294 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.Frame.ActivateViewControllers() Line 174 DevExpress.ExpressApp.v22.2.dll!DevExpress.ExpressApp.Frame.SetView(DevExpress.ExpressApp.View view, bool updateControllers, DevExpress.ExpressApp.Frame sourceFrame, bool disposeOldView) Line 459 DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.BlazorApplication.CreateStartupWindow(DevExpress.ExpressApp.Actions.PopupWindowShowAction startupAction, bool isLogonAction) Line 176 DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Pages.LoginPageBase.GetLogonWindowContent(DevExpress.ExpressApp.Blazor.BlazorApplication application) Line 64 DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Pages.LoginPage.BuildRenderTree.AnonymousMethod__0_0(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder2) Line 13 DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Components.XafExceptionHandler.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) Line 6 Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.ComponentBase..ctor.AnonymousMethod__6_0(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder, Microsoft.AspNetCore.Components.RenderFragment renderFragment, out System.Exception renderFragmentException) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessPendingRender() Unknown Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer.ProcessPendingRender() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, Microsoft.AspNetCore.Components.RenderFragment renderFragment) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(Microsoft.AspNetCore.Components.ParameterView directAndCascadingParameters) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(Microsoft.AspNetCore.Components.ParameterView parameters) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(int componentId, Microsoft.AspNetCore.Components.ParameterView initialParameters) Unknown Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost.InitializeAsync.AnonymousMethod__0() Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.InvokeAsync.AnonymousMethod__9_0(object state) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(System.Threading.Tasks.TaskCompletionSource<object> completion, System.Threading.SendOrPostCallback d, object state) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronouslyIfPossible(System.Threading.SendOrPostCallback d, object state) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.InvokeAsync(System.Func<System.Threading.Tasks.Task> asyncAction) Unknown Microsoft.AspNetCore.Components.dll!Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContextDispatcher.InvokeAsync(System.Func<System.Threading.Tasks.Task> workItem) Unknown Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost.InitializeAsync(Microsoft.AspNetCore.Components.ProtectedPrerenderComponentApplicationStore store, System.Threading.CancellationToken cancellationToken) Unknown Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.Server.ComponentHub.StartCircuit(string baseUri, string uri, string serializedComponentRecords, string applicationState) Unknown [Lightweight Function] Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub>.ExecuteMethod(Microsoft.Extensions.Internal.ObjectMethodExecutor methodExecutor, Microsoft.AspNetCore.SignalR.Hub hub, object[] arguments) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub>.ExecuteHubMethod(Microsoft.Extensions.Internal.ObjectMethodExecutor methodExecutor, Microsoft.AspNetCore.Components.Server.ComponentHub hub, object[] arguments, Microsoft.AspNetCore.SignalR.HubConnectionContext connection, System.IServiceProvider serviceProvider) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub>.Invoke.__ExecuteInvocation|16_0(Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub> dispatcher, Microsoft.Extensions.Internal.ObjectMethodExecutor methodExecutor, Microsoft.AspNetCore.Components.Server.ComponentHub hub, object[] arguments, Microsoft.Extensions.DependencyInjection.AsyncServiceScope scope, Microsoft.AspNetCore.SignalR.IHubActivator<Microsoft.AspNetCore.Components.Server.ComponentHub> hubActivator, Microsoft.AspNetCore.SignalR.HubConnectionContext connection, Microsoft.AspNetCore.SignalR.Protocol.HubMethodInvocationMessage hubMethodInvocationMessage, bool isStreamCall) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub>.Invoke(Microsoft.AspNetCore.SignalR.Internal.HubMethodDescriptor descriptor, Microsoft.AspNetCore.SignalR.HubConnectionContext connection, Microsoft.AspNetCore.SignalR.Protocol.HubMethodInvocationMessage hubMethodInvocationMessage, bool isStreamResponse, bool isStreamCall) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<Microsoft.AspNetCore.Components.Server.ComponentHub>.ProcessInvocation(Microsoft.AspNetCore.SignalR.HubConnectionContext connection, Microsoft.AspNetCore.SignalR.Protocol.HubMethodInvocationMessage hubMethodInvocationMessage, bool isStreamResponse) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher<System.__Canon>.DispatchMessageAsync(Microsoft.AspNetCore.SignalR.HubConnectionContext connection, Microsoft.AspNetCore.SignalR.Protocol.HubMessage hubMessage) Unknown Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.HubConnectionHandler<Microsoft.AspNetCore.Components.Server.ComponentHub>.DispatchMessagesAsync(Microsoft.AspNetCore.SignalR.HubConnectionContext connection) Unknown [Resuming Async Method] System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread threadPoolThread, System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<Microsoft.AspNetCore.SignalR.HubConnectionHandler<Microsoft.AspNetCore.Components.Server.ComponentHub>.<DispatchMessagesAsync>d__20>.MoveNext(System.Threading.Thread threadPoolThread) Unknown System.Private.CoreLib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown System.Private.CoreLib.dll!System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() Unknown System.Private.CoreLib.dll!System.Threading.Thread.StartCallback() Unknown [Async Call Stack] [Async] Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.HubConnectionHandler<Microsoft.AspNetCore.Components.Server.ComponentHub>.RunHubAsync(Microsoft.AspNetCore.SignalR.HubConnectionContext connection) Unknown [Async] Microsoft.AspNetCore.SignalR.Core.dll!Microsoft.AspNetCore.SignalR.HubConnectionHandler<Microsoft.AspNetCore.Components.Server.ComponentHub>.OnConnectedAsync(Microsoft.AspNetCore.Connections.ConnectionContext connection) Unknown [Async] Microsoft.AspNetCore.Http.Connections.dll!Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionContext.ExecuteApplication(Microsoft.AspNetCore.Connections.ConnectionDelegate connectionDelegate) Unknown [Async] System.Private.CoreLib.dll!System.Threading.Tasks.Task.WhenAny Unknown [Async] Microsoft.AspNetCore.Http.Connections.dll!Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionDispatcher.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Connections.ConnectionDelegate connectionDelegate, Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions options, Microsoft.AspNetCore.Http.Connections.Internal.ConnectionLogScope logScope) Unknown [Async] Microsoft.AspNetCore.Http.Connections.dll!Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionDispatcher.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions options, Microsoft.AspNetCore.Connections.ConnectionDelegate connectionDelegate) Unknown [Async] Microsoft.AspNetCore.Routing.dll!Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke.__AwaitRequestTask|6_0(Microsoft.AspNetCore.Http.Endpoint endpoint, System.Threading.Tasks.Task requestTask, Microsoft.Extensions.Logging.ILogger logger) Unknown [Async] DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Services.SignInMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Line 104 [Async] DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Services.ImageResourcesMiddleware.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Line 73 [Async] DevExpress.ExpressApp.Blazor.v22.2.dll!DevExpress.ExpressApp.Blazor.Services.FileDataResourcesMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context, DevExpress.ExpressApp.AspNetCore.Streaming.IFileService fileService) Line 107 [Async] DevExpress.ExpressApp.AspNetCore.v22.2.dll!DevExpress.ExpressApp.Blazor.AmbientContext.ValueManagerContextMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context, DevExpress.ExpressApp.Blazor.Services.IValueManagerStorageContainerInitializer storageContainerAccessor) Line 52 [Async] Microsoft.AspNetCore.Authorization.Policy.dll!Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown [Async] Microsoft.AspNetCore.Authentication.dll!Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown [Async] Microsoft.AspNetCore.Localization.dll!Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown [Async] Microsoft.AspNetCore.Diagnostics.dll!Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown [Async] Microsoft.AspNetCore.Server.IIS.dll!Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT<Microsoft.AspNetCore.Hosting.HostingApplication.Context>.ProcessRequestAsync() Unknown [Async] Microsoft.AspNetCore.Server.IIS.dll!Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.HandleRequest() Unknown

        So it seems to be failing when creating a "Shared Application"

        Answers approved by DevExpress Support

        created 2 years ago

        Hello, Michael.

        Thank you for your update. It helped us track the cause of this behavior down to the changes we made a year ago for Blazor and Web API Service. You can learn more about this at Core - ValueManager API availability and deprecated static helpers in XAF .NET 6+ apps (Blazor, Web API Service, WinForms). These architectural changes are irreversible.

        We can recommend that you use a more robust/reliable solution for ASP.NET Core: obtain connection string information without the NavigationManager service, rather read URL information from HttpContext as described here: Blazor - Obtain request information from HttpContext (query string parameter) for auto login from URL. Even in v22.1, your current code would not work for certain scenarios with the Reports module because it used new architecture from the very beginning.
        Our solution will work even for non-visual scenarios when various middle-ware services of ASP.NET Core and XAF are used. In other words, XafApplication setup may happen at various moments and not necessarily when you need it for your particular task.

        I hope you can refactor your code to use IHttpContextAccessor (please consider the limitations of this approach for Azure as noted in the article).

          Show previous comments (2)
          M M
          Michael de Vlieger a year ago

            Instead of using the subdomain I refactored the application accordingly to https://github.com/DevExpress-Examples/XAF_how-to-change-connection-to-the-database-at-runtime-e1344/

            I use my own service to detect the tennant instead of a drop down (works)

            However, when I log out and login with a different tennant, it will fail, because the database updater is not called.

            Is there any way to trigger the module updaters after each login.

            It should be, because the modules can differ per tennant too.

            Dennis Garavsky (DevExpress) a year ago

              Hello,

              I created a separate ticket on your behalf: T1191645: How to always call the database updater in E1344 (for scheme changes based on tenants). We placed it in our processing queue and will process it shortly.

              M M
              Michael de Vlieger a year ago

                Thank you, Dennis!

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.