Current filter:
                                You should refresh the page.
                                  • NOTE: Mobile UI is currently in maintenance mode. See additional information in the FAQ: XAF Mobile UI (Maintenance Mode) article.
                                    The article is intended only for developers with legacy Mobile applications. The ASP.NET Core Data Service from this article is provided "as is" and will not get new updates.

                                    Changes in v19.2
                                    As of August 2019, we officially canceled XAF's React-based SPA UI project to focus our efforts on Blazor going forward. For more information, see XAF - Important Changes to the SPA UI Strategy: The Future is Blazor.
                                    Since the ASP.NET Core Data Service used in this article was a part of SPA UI, we've updated the example so that you can continue using your Mobile projects in version 19.2. The updated version is attached in the file.
                                    The project has the following changes:

                                    1. A new MobileDataService project with classes required for the ASP.NET Core Data Service was added. You need to reference it in your *.Spa project. Old references to DevExpress.ExpressApp.Spa will not work - remove them from your projects.
                                    2. The following using directives are obsolete:

                                    Here are their counterparts from the MobileDataService project:

                                    3. The following extension methods are not available:
                                    public static IMvcBuilder AddXaf\<T\>(this IServiceCollection services) where T : XafApplication public static IApplicationBuilder UseXaf(this IApplicationBuilder app)

                                    Use the following code instead:

                                    //services.AddXaf<YourMobileApplicationClassName>().AddDefaultReportingControllers(); services.AddScoped<IAuthenticationActionFilter, AuthenticationActionFilter>(); services.AddScoped<AuthenticationServiceAdapter>(); services.AddScoped<PrincipalSecurityAdapter>(); services.AddSpaApplicationServices<YourMobileApplicationClassName>(); services.ConfigureSpaApplicationRouting(); //app.UseXaf(); app.UseMiddleware<RequestCultureMiddleware>(); app.UseMiddleware<RequestSecurityMiddleware>();

                                    Old content
                                    This article describes how to connect an existing XAF Mobile application to the new ASP.NET Core Data Service shipped in v18.2. Use this service to get the following benefits:
                                    - Non-persistent objects support;
                                    ContainsOperator and aggregate functions in ListView filters (Free Joins are not yet supported);
                                    - Displaying List Views of non-associated collections;
                                    - Filtering lookups by an arbitrary (non-associated) DataSourceProperty.
                                    If you use these features in your Mobile application, check the "Known behavior" section at the end of this article.

                                    XAF v18.2.4+ and Visual Studio 2017+ with .NET Framework 4.6.1+ are required.
                                    XPO classes and non-persistent POCO are supported for data access. Entity Framework (EF) and Domain Components (DC) interfaces are not supported.

                                    Attached files
                                    The archive contains the following folders:
                                    DemoApplication.Spa with the Data Service that can be attached to your XAF Mobile application;
                                    MobileDemoApplication with a sample XAF Mobile application connected to this service.

                                    Steps to implement
                                    1.  Data Service configuration.
                                    1.0 (required in v19.2+) Add the MobileDataService project to your XAF solution.
                                    1.1 Include the data service project (DemoApplication.Spa in our example) into your XAF solution. Update its references using the Project Converter and call the Restore NuGet Packages command if necessary.
                                    1.2 Add references to your XAF Application’s assemblies to the service project. Typically, these are:

                                    1.3 Replace the YourMobileApplicationClassName placeholder in the DemoApplication.Spa\Startup.xx file with the name of your MobileApplication descendant from the Mobile project.
                                    1.4 Configure the ConnectionString parameter of the DemoApplication.Spa\app.config file to specify the service’s database connection. Insert the connection string of your Mobile application there.

                                    2.  Security setup.
                                    2.1 If your Mobile application does not use the Security module, remove the following lines of code from the DemoApplication.Spa\Startup.xx file:

                                    SetUpAuthentication(services); ... app.UseMiddleware<RequestSecurityMiddleware>();
                                    SetUpAuthentication(services) ... app.UseMiddleware(Of RequestSecurityMiddleware)()

                                    2.2 If your Mobile application uses Security, change its authentication type to AuthenticationMixed. Here is an example of how to do this in the MobileApplication.xx file:

                                    using DevExpress.ExpressApp.Security; using DevExpress.Persistent.BaseImpl.PermissionPolicy; public partial class MobileDemoApplicationMobileApplication : MobileApplication { public MobileDemoApplicationMobileApplication() { ... AuthenticationMixed authenticationMixed = new AuthenticationMixed(); authenticationMixed.LogonParametersType = typeof(AuthenticationStandardLogonParameters); authenticationMixed.IsSupportChangePassword = true; authenticationMixed.AddAuthenticationStandardProvider(typeof(PermissionPolicyUser)); authenticationMixed.AddIdentityAuthenticationProvider(typeof(PermissionPolicyUser)); ((SecurityStrategyBase)Security).Authentication = authenticationMixed; }
                                    Imports DevExpress.ExpressApp.Security Imports DevExpress.Persistent.BaseImpl.PermissionPolicy Partial Public Class MobileDemoApplicationMobileApplication Inherits MobileApplication Public Sub New() ... Dim _AuthenticationMixed As New AuthenticationMixed() _AuthenticationMixed.LogonParametersType = GetType(AuthenticationStandardLogonParameters) _AuthenticationMixed.IsSupportChangePassword = True _AuthenticationMixed.AddAuthenticationStandardProvider(GetType(PermissionPolicyUser)) _AuthenticationMixed.AddIdentityAuthenticationProvider(GetType(PermissionPolicyUser)) CType(Security, SecurityStrategyBase).Authentication = _AuthenticationMixed End Sub

                                    AuthenticationMixed is required to use multiple authentication methods in the same application. The new Data Service uses AuthenticationStandardProvider for the initial logon and IdentityAuthenticationProvider for user request authentication.
                                    The Mobile application modified in this manner remains compatible with the former Data Service.

                                    3.  Check how the Data Service starts.
                                    Launch the service project (DemoApplication.Spa). If everything is configured correctly, you will see the following result:
                                    With Security

                                    Without Security

                                    4.  Connect your application to the Data Service.
                                    Add the following key to your Mobile application’s web.config:

                                    <appSettings> ... <add key="DataServiceUrl" value="http://localhost:51583/api"/> </appSettings>

                                    The service’s port can be copied from the project's settings (launchSettings.json) or from the browser, as shown in the previous step.

                                    5.  Copy the YourSolutionName.Mobile\Model.xafml file to the service's output directory (e.g., DemoApplication.Spa\bin\Debug\net461).
                                    You can do this by adding this file to the DemoApplication.Spa project and setting its Copy to Output Directory parameter to Copy Always. Note that the service's Model.xafml file should always contain the most recent version of the YourSolutionName.Mobile\Model.xafml file.
                                    In the attached example, the file is copied using the following post-build event command line in the MobileDemoApplication.Mobile project:
                                    copy /Y "$(SolutionDir)$(ProjectName)\Model.xafml" "$(SolutionDir)\DemoApplication.Spa

                                    6.  Run the application.
                                    With this configuration, it is necessary to start the Mobile application (YourSolutionName.Mobile) and the Data Service (DemoApplication.Spa) together. To do this, configure the Multiple startup projects parameter in the Visual Studio solution settings as follows.

                                    Alternatively, launch the Data Service and then the Mobile application manually.

                                    This article shows a basic implementation of an ASP.NET Core Data Service that can be used with existing XAF Mobile applications. You may need to change its source code to support your scenarios. Take the following implementation specificities into account:
                                    1.  By default, Mobile applications use the System.Web.HttpContext.Current.Application object to cache XpoDataStoreProvider in the GetDataStoreProvider method. The demonstrated service is based on ASP.NET Core and cannot use this caching. So, a new SQL connection will be created for each request.
                                    2.  CORS is disabled in the attached Data Service through the following settings: AllowAnyOriginAllowCredentialsAllowAnyMethodAllowAnyHeader. This allows launching the Data Service and the Mobile application with different ports without additional configuration.
                                    3.  The resulting project will use the YourSolutionName.Mobile project's connection string to build the client application. So, connection parameters should also be specified in YourSolutionName.Mobile\Web.config.

                                    Known behavior
                                    1.  To show a non-persistent object's Detail View from a ListView, handle the NonPersistentObjectSpace.ObjectByKeyGetting event.
                                    2.  Custom members created dynamically in code or in the Model Editor are not supported out of the box. See a possible workaround in the following ticket: Mobile - Can I use custom members with the ASP.NET Core Data Service?
                                    3.  When a non-associated collection property returns a collection whose records are already loaded (e.g., List<T>), filters from the ListView.CollectionSource.Criteria property are not applied to it.

                                • Nate Laff 10.25.2018

                                  Here's what would be super rad. If this data service could talk to some kind of remoting service on another PC. For example, let me host the ASP.NET Core data service on my web server, meanwhile, each of my users have their own database on their PC. Requests could contain info about which connection its headed towards, and send to some remoting service on that end (so I don't need to open up port forwarding).

                                  This would be an extreme help. I feel like you're getting pretty close to making this a reality.

                                • Petr Zima 02.27.2019


                                  I tried this example at 18.2.4 and it worked verry well. Now I upgraded to latest version (18.2.6) and this example is no more functional. Spa project gets 500 error without any other informations. Can you please validate if this demo is working with version 18.2.6?

                                  (btw I upgraded Spa project dependencies with nuget system to latest version as well)

                                  Thank you for your time.

                                • Anatol (DevExpress Support) 02.27.2019

                                  Hello Petr,

                                  I checked this project with version 18.2.6. I did the following steps:

                                  1. Updated the project's references using the Project Converter tool.
                                  2. Updated the DevExtreme.AspNet.Data NuGet package to version 2.1.1 in the NuGet Package Manager.
                                  3. Restored the project's NuGet Packages.

                                  This was sufficient to run the project. I have also attached updated projects to this article. If this does not help, please create a separate ticket and provide a sample project and error details.

                                • Jacek Kosiński 04.26.2019

                                  is possible to use SPA UI data serice with non Xaf application ? How can i do it ?

                                • Anatol (DevExpress Support) 04.29.2019

                                  Yes, you can reuse certain parts of this Data Service. Please see additional information in the following ticket: How to use the new ASP.NET Core Data Service for SPA UI to query data from external clients.

                                0 Solutions

                                Creation Date Importance Sort by