ASP. NET Zero -- backend application, asp. netzero -- backend

Source: Internet
Author: User
Tags change settings subdomain subdomain name

ASP. NET Zero -- backend application, asp. netzero -- backend
Backend applications

This is the actual application for user name and password input. You will mainly add your business requirements on this application.

Application folder

By default, backend applications are built in a dedicated area named "App", but can be determined when creating a solution. Therefore, all controllers, views, and models are located in the Areas/App folder. In addition, the scripts and style files are located in the wwwroot/view-resources/Areas/App folder, as shown below:

Main Menu

The main menu of the application is defined in the AppNavigationProvider class. For more information about the menu creation, see the ABC navigation document. When you add a new menu item, it is automatically displayed in the layout.

Layout

The application Layout is located in the Areas/App/Views/Layout folder. It uses the header, footer, and Sidebar of the component:

The main menu is displayed in the sidebar component. The layout is also highly bundled and compressed (see below) system scripts and styles include.

Version Management

Skip this section if you have not developed a multi-tenant application.

Most SaaS (Multi-tenant) applications have different feature versions (packages ). Therefore, they can provide different price and function options for their tenants (customers. The version page (which can be used during host Logon) is used to manage the application version:

The version is used to group function values and assign them to tenants. When we click operation/edit of a version, we can see its assigned functions:

The startup project only contains two sub-functions that can enable/disable chat for each version/tenant ). All functions are defined in the AppFeatureProvider class. The feature values are stored in the AbpFeatures table. The function is not limited to boolean (enable/disable) values and can contain different types of values, as shown below:

For more information, see function management and Version Management documentation.

Tenant Management

Skip this section if you have not developed a multi-tenant application.

If this is a multi-tenant application and you log on as the host user, the tenant page is displayed:

Tenants are represented by tenant classes. You can expand the tenant class by adding a new property class. Only one tenant. The Default value is Default. The tenant name (codename) is the unique name of the tenant. Tenants can be activated or locked. If it is locked, the user of this tenant cannot log on to the application.

When we click "create new tenant", a dialog box is displayed:

The lease name must be unique and cannot contain spaces or other special characters, because it can be used as a subdomain name (such as tenancyname.mydomain.com. See the following section ). The name can be anything. The Administrator email is used as the email address of the administrator user of the new customer. The user will automatically create an administrator user. We can set a random password for the administrator and send an activation email. When the user logs on for the first time, he/she should change the password. You can deselect this option to enter a known password.

When creating a new tenant, we should select/create a database to store the data of the new tenant. You can select "use host database" to store tenant data in the host database (which can be used for a single database method), or specify a connection string to create/use a dedicated database for the new tenant. AspNet Zero supports the hybrid mode. This means that you can use the host database for some tenants and create a dedicated database for other tenants. Even if you can group some tenants in a separate database.

All tenant operations are handled by the TenantAppService class. Example (delete tenant ):

[AbpAuthorize(AppPermissions.Pages_Tenants_Delete)] public  async Task DeleteTenant(EntityRequestInput input){    var tenant = wait TenantManager.GetByIdAsync(input.Id);    CheckErrors(wait TenantManager.DeleteAsync(tenant));}

TenantAppService uses the TenantManager Domain Name Service for tenant operations.

Tenant edition and features

A version can be assigned to a tenant (created or edited ). The tenant inherits all functions of the assigned version. However, we can also cover the functions and values of tenants. Click the tenant operation/change feature to customize its features:

Tenant user imitation

As host users, we may want to perform operations on behalf of tenants. In this case, you can click "log on to this tenant" in the operation. When we click it, we can see a mode to select tenant users. You can select any user and perform operations that allow the user. For more information, see the "User Simulation" section in this document.

Use the lease name as a subdomain name

Multi-tenant applications generally use subdomains to identify the current tenant. Tenant1 .mydomain.com, tenant2 .mydomain.com, etc. ASP. NET Zero automatically identifies and obtains the tenant name from the subdomain (see host settings ).

Organization Unit

Organization units (OU) are used to group users and entities hierarchically. Then you can obtain users or entities based on their OU. When we click manage/organizational unit, we enter the relevant page:

Here, we can manage OU (create, edit, cancel, move) and members (Add/delete ).

OrganizationUnitManager is used to manage OU, and UserManager is used to manage OU members in code. OrganizationUnitAppService executes the application logic.

In the left OU tree, right-click an OU (or left-click the arrow on the right) to open the context menu of the OU operation. When we try to add a member, a mode is displayed to select the user:

This is actually a common search mode that can be used to select any type of entities (see region/application/View/public/Modal/_ LookupModal. cshtml and Its Related script files ). To select a user, we create the FindUsers method CommonLookupAppService and then configure the mode to use this method (see scenario resource/zone/application/Browse/OrganizationUnits/index. js is lookupModal. open files ).

For more information, see organizational unit management files.

Role management

Click Manage/role to go To the role management page:

Roles are used for group permissions. When a user has a role, he/she has all permissions for the role.

The Role is represented by the Role class. The role class can be extended by adding new attributes.

RoleManager executes the domain logic, and RoleAppService executes the application logic of the role.

The role can be dynamic or static:

  • Static role: the static role has a known name (such as "admin") and cannot be changed (we can change the display name ). It exists at system startup and cannot be deleted. Therefore, you can write code based on the static role name.
  • Dynamic Role: You can create a dynamic role after deployment. Then we can grant this role permissions. We can assign the role to some users and delete it. We cannot know the dynamic role name during the development time.

One or more roles can be set as default. Default roles are assigned to new users by default. This is not a property during development. You can set or change it after deployment.

In the startup project, we have a static administrator role for the host (for multi-tenant applications. In addition, we provide static administrator and user roles for tenants. All permissions are granted to the management role by default. A user role is the default role of a new user. By default, it has no permissions. These can be easily changed. For more information about all static roles, see StaticRoleNames class and AppRoleConfig for changing static roles.

Role Permissions

Because a role is used for group permissions, you can set permissions when creating or editing a role, as shown below:

(Not all permissions are shown in)

Each tenant has its own role. Any change to the tenant role will not affect other tenants. In addition, the host also has its own role.

User Management

When you click manage/user menu, the user management page is displayed:

A user is a person who can log on to the application and perform certain operations based on his/her permissions.

The user class represents the user. You can expand the user class by adding new attributes.

UserManager is used to execute the domain logic, and UserAppService is used to execute the application logic for the user.

You can have zero or more roles. If a user has multiple roles, the user inherits the permissions of all these roles. In addition, we can set user-specific permissions. The user-specific permission settings will overwrite the role settings for this permission. In the user permission dialog box:

(Not all permissions are shown in)

The dialog box is used to create/edit a user:

We can change the user password so that it can be activated/locked... the user has a profile image. Users can change the settings (see user menu ). The administrator user cannot be deleted as a business rule. If you do not want to use the administrator, you can lock it.

User Simulation

As an administrator (or any user allowed), we may want to log on as a user and perform operations on behalf of the user without knowing his or her password. When we click "Log on as this user" in the user's operations, we will automatically redirect and Log On As this user. This is called "User Simulation ". When we simulate a user, the "back to my account" option is added to the user configuration file menu:

In a simulated account, we can only perform operations permitted by this user. This means that everything can be used as the same user's login capability. The only difference is shown in the audit log, which indicates that the operation is performed by others. Note: A red "return" icon is displayed near the user name, indicating that you are in a simulated account.

Simulate in the AccountController of the Web Project.

Language Management

The language Management page is used to manage (Add/edit/delete) the application language and change the localized text:

You can create a new language, edit or delete an existing language, and set the language to the default language. Note: The tenant cannot edit/Delete the default language, but the host user can.

When we click to change the text of any language, we are redirected to a new view to edit the language text:

We can select any language as the basis (reference) and change the text of the target language. The basic language is only used to help with the translation progress. Because there may be different localization sources, we select the source to be translated. When we click the edit icon, we can see the editing mode of the selected text:

The host user (if allowed) can edit the language and localized text. These languages are default for all tenants of Multi-tenant applications. The tenant inherits the language and localized text, which can overwrite the localized text or add a new language.

Both pages use the LanguageAppService class as the application service. It provides methods for managing languages and localized texts. The IApplicationLanguageManager and IApplicationLanguageTextManager interfaces are used to execute domain logic (used by LanguageAppService ).

For more information, see the language management and localization documentation.

Audit Log

On the audit log page, we can see interaction with all users of the application:

All application service methods and MVC controller operations are automatically recorded. You can view them here. See the audit log document to learn how to configure. When we click the magnifier icon, we can see that all the details are an audit log:

Audit Log reports are provided by the AuditLogAppService class.

Host settings

The host settings page is used to configure some system settings:

Time zone is an important setting on this page. AspNet Zero can work in multiple regions. Each user can view the date and time in their own time zone. The Time Zone settings on this page allow you to set the default time zone for applications (including all tenants and users. Tenants and users can change the time zone in their own settings. The Time Zone settings are only available when the UTC clock is used. See the documentation to switch to UTC.

The save all button can save all settings with one click. HostSettingAppService is used to retrieve and Save settings. (For more information, see setting providers ).

The "security" tab on the host settings page contains Password Complexity and other security settings. Hosts can define system-wide security settings on this tab. Each tenant can override this setting on the tenant settings page. The PasswordComplexityChecker class checks whether the Password meets the Password Complexity settings.

Tenant settings

In a multi-tenant application, the tenant settings are as follows:

If multi-tenant is disabled, some host settings will be displayed on this page (because there is no host settings page ). The tenant can also define the Password Complexity settings, or use the Password Complexity settings defined by the host user.

TenantSettingAppService is used to obtain/set tenant settings.

Enable LDAP (active directory) Authentication

By default, LDAP (Active Directory) disables authentication. To make it work, we should disable multi-tenant because LDAP auth will not be used normally in the Multi-tenant system. In the CoreModule class of the. Core Project, we should enable the following lines:

Configuration.Modules.ZeroLdap().Enable(typeof(AppLdapAuthenticationSource));

Then, we can see the LDAP Settings section on the settings page:

We can check "enable LDAP authentication" to enable it. If the server runs a domain user or local system in the domain and application, you do not need to set the domain name, user, and password. You can log out and use your domain user name and password to log on. If not, set these creden.

. Net core compatibility

LDAP authentication is not supported by. net core. Therefore, it is designed as conditional. If you are using. Net Framework (4.6 +), it will be available, otherwise it will be disabled.

Maintenance

The maintenance page can be used on the host side of a Multi-tenant application (the Single-tenant application is displayed on the tenant side), as shown below:

On the cache tab, we can clear some or all caches. If you manually change the database and want to refresh the application cache, you may need to clear the cache. CachingAppService is used to clear the cache on the server.

The website Log tab is used to view and download logs:

WebLogAppService is used to obtain logs from the server.

Tenant dashboard

The ASP. NET Zero startup project also contains the sample dashboard. This is only for demonstration purpose. You can use it as the starting point of the actual dashboard:

Here, only the Member activity diagram Data is retrieved from the server (from TenantDashboardAppService. You can click the refresh button to generate a random graph.

Notification

The notification icon is next to the language selection button. The number in the red circle shows the number of unread notifications.

You can click this icon to view the three most recent notifications.

You can click the "set all to all" link to mark all notifications as read, or click the "set to read" link next to each notification to mark a single notification.

The notification is sent in real time using SignalR. In addition, desktop push notifications are displayed when you receive notifications.

Notification Settings

The "Settings" link opens the Notification Settings dialog box.

In this dialog box, there is a global setting for enabling/disabling notification reception. If this setting is enabled, you can enable/disable each notification separately.

You can also define custom notifications in the AppNotificationProvider class. For example, the registration notification of a new user is defined in the AppNotificationProvider as follows.

context.Manager.Add(      new NotificationDefinition(        AppNotificationNames.NewUserRegistered,        displayName:L(“NewUserRegisteredNotificationDefinition”),        permissionDependency:new SimplePermissionDependency(AppPermissions.Pages_Administration_Users)    ));

For more information, see notification definitions.

The AppNotifier class is used to publish notifications. NotificationAppService class is used to manage the application logic of notifications. For more information, see the notification documentation.

Notification

All user notifications are listed on this page.

. Net core compatibility

Because SignalR is not ready for. net core, real-time notification does not work if you select. net core as the basic framework.

Chat

The chat icon is located next to the user profile image in the upper-right corner of the page. The number in the red circle shows the number of unread chat messages.

When you click this icon, the chat panel appears on the right side of the page. This Panel contains a list of user friends and blocked users.

You can add new friends by writing the user name to the User Name text box in the friend list. If the "chat with other tenants" function is enabled for tenants, users of other tenants can be added as friends by writing [tenant name] \ [user name] (for example, Default \ admin. If the "chat with the host user" function is enabled, the host user can write data in the same text box. \ [Username] is added as a friend.

Although there is a green circle on the pictures of online friends/users' profile, offline friends/users all have a gray circle.

You can click the needle icon in the upper-right corner of the chat panel to locate or unopen the chat panel. The application tries to remember the last status of the chat panel and restores the status when the user logs on to the application.

When a friend or user is selected, the session Panel is opened.

Users can block or remove friends/users in this region. The selected user name has a wrench icon on the right. This icon opens an operation menu that contains block users or unblocks user operations based on their block status.

Chat messages are transmitted by using the ChatHub signalR hub class of the ChatMessageManager domain class.

The ChatUserStateWatcher class is responsible for viewing the online/offline status changes of chat users. When a user goes online or offline, this type captures status changes and notifies related users of friends.

The FriendshipAppService and FriendshipManager classes are responsible for managing friendship requests. Chat messages from blocked users are not transmitted to target users.

Because chat is a real-time operation, the application caches the number of unread messages of friends and friends of online users. The UserFriendsCache class manages these cache operations.

The UserFriendCacheSyncronizer class is responsible for keeping users' friends cached up to date. To do this, it will watch events of the Friendship and ChatMessage entities.

. Net core compatibility

Because SignalR is not ready for. net core, if you select. net core as the basic framework, the chat function will not work properly.

Chat

The system has three chat functions. These are "chat", "chat with the Host", and "chat with other tenants ". Each version/tenant can enable/disable these features. By using these features, the host can enable/disable chatting with users of other tenants or host users.

User menu

You can click the name in the upper-right corner to open the user menu:

Linked account

Linked accounts are used to link multiple accounts to each other. In this way, users can use this function to easily browse their/her accounts.

You can click the "manage account" link to link a new account or delete an linked account.

To connect to a new account, you must enter the logon creden。 of the account.

The UserLinkAppService class is used to manage the application logic of account links, and the UserLinkManager class is used to manage the domain logic of account links.

Configuration File Settings

My settings are used to change the User Configuration File Settings:

As shown below, the administrator user name cannot be changed. It is considered a special user name because it is used for database migration seeds. Other users can change their usernames. ProfileAppService is used to get/change settings.

Logon Attempt

All logon attempts (successful failures) are recorded in the application. The user can see the last logon attempt of his/her account. UserLoginAppService is used to obtain logon attempts from the server.

Change Image

Users can change their profile images. ProfileController is used to upload and obtain user profile images. Currently, jpg/jpeg, gif, and png files are supported, and you can expand them.

Change Password

ProfileAppService is used to change the password.

Logout

AccountController is used to log out of a user and redirect to the logon page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.