修复 aspnetboilerplate 启动模板、租户或编辑错误

Fix aspnetboilerplate startup template, tenant or edit with errors

我正在尝试将 AspBoilerPlate 作为一个框架,因为它看起来非常好,而且我一直很难尝试在 Owin Identity 上获得多租户(几天前我发布了一个问题:Asp.Net Identity Multitenant

我下载了 Asp.Net MVC,这样我就可以移植我已有的代码,从头开始我可以登录的负载创建用户、租户但是,在任何视图上,如果我单击编辑它说发生错误,在登录视图中如果我单击更改租户发生错误。

这是我采取的步骤(尝试了 ASP.Net MVC 和核心版本):

  1. 在 VS 2019 上下载/解压/打开并加载
  2. 更改 web.config
  3. 上的连接字符串
  4. 运行 来自 EntityFramework 项目
  5. 控制台的更新数据库
  6. 启动应用程序

它有效,但存在我上面描述的错误。

我在 VS 上使用了 step into 函数来尝试获取真正的错误,但它可能会在外部 dll 或其他东西上捕获它,这是干净的 log.txt 只执行 Load-Login-Change tenant (错误)- 登录 - 编辑租户(错误)

DEBUG 2019-09-24 13:12:59,986 [1    ] Abp.Modules.AbpModuleManager             - Found 17 ABP modules in total.
DEBUG 2019-09-24 13:12:59,995 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: myapplication.Web.myapplicationWebModule, myapplication.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:12:59,997 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: myapplication.myapplicationDataModule, myapplication.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:12:59,997 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Zero.EntityFramework.AbpZeroEntityFrameworkModule, Abp.Zero.EntityFramework, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:12:59,998 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Zero.AbpZeroCoreModule, Abp.Zero, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:12:59,999 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Zero.AbpZeroCommonModule, Abp.Zero.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:12:59,999 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.AbpKernelModule, Abp, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,006 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.EntityFramework.AbpEntityFrameworkModule, Abp.EntityFramework, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,006 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.EntityFramework.AbpEntityFrameworkCommonModule, Abp.EntityFramework.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,007 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: myapplication.myapplicationCoreModule, myapplication.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,007 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: myapplication.myapplicationApplicationModule, myapplication.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,012 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.AutoMapper.AbpAutoMapperModule, Abp.AutoMapper, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,012 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: myapplication.Api.myapplicationWebApiModule, myapplication.WebApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,013 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.WebApi.AbpWebApiModule, Abp.Web.Api, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,013 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Web.AbpWebModule, Abp.Web, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,013 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Web.AbpWebCommonModule, Abp.Web.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,014 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Web.SignalR.AbpWebSignalRModule, Abp.Web.SignalR, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,014 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Web.Mvc.AbpWebMvcModule, Abp.Web.Mvc, Version=4.9.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:00,018 [1    ] Abp.Modules.AbpModuleManager             - 17 modules loaded.
DEBUG 2019-09-24 13:13:03,252 [1    ] o.Configuration.LanguageManagementConfig - Converted Abp (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource
DEBUG 2019-09-24 13:13:03,252 [1    ] o.Configuration.LanguageManagementConfig - Converted AbpZero (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource
DEBUG 2019-09-24 13:13:03,252 [1    ] o.Configuration.LanguageManagementConfig - Converted myapplication (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource
DEBUG 2019-09-24 13:13:03,252 [1    ] o.Configuration.LanguageManagementConfig - Converted AbpWeb (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource
DEBUG 2019-09-24 13:13:03,865 [1    ] EntityFramework.AbpEntityFrameworkModule - Registering DbContext: myapplication.EntityFramework.myapplicationDbContext, myapplication.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-24 13:13:06,085 [1    ] Abp.Localization.LocalizationManager     - Initializing 4 localization sources.
DEBUG 2019-09-24 13:13:06,161 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: Abp
DEBUG 2019-09-24 13:13:06,219 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: AbpZero
DEBUG 2019-09-24 13:13:06,247 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: myapplication
DEBUG 2019-09-24 13:13:06,280 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: AbpWeb
DEBUG 2019-09-24 13:13:06,391 [1    ] Abp.BackgroundJobs.BackgroundJobManager  - Start background worker: Castle.Proxies.BackgroundJobManagerProxy
DEBUG 2019-09-24 13:13:06,468 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - Found 11 classes define auto mapping attributes
DEBUG 2019-09-24 13:13:06,469 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Sessions.Dto.TenantLoginInfoDto
DEBUG 2019-09-24 13:13:06,477 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Sessions.Dto.UserLoginInfoDto
DEBUG 2019-09-24 13:13:06,478 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Users.Dto.CreateUserDto
DEBUG 2019-09-24 13:13:06,479 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Users.Dto.UpdateUserDto
DEBUG 2019-09-24 13:13:06,479 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Users.Dto.UserDto
DEBUG 2019-09-24 13:13:06,479 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Roles.Dto.PermissionDto
DEBUG 2019-09-24 13:13:06,479 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.MultiTenancy.Dto.CreateTenantDto
DEBUG 2019-09-24 13:13:06,480 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.MultiTenancy.Dto.EditTenantDto
DEBUG 2019-09-24 13:13:06,480 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.MultiTenancy.Dto.TenantDto
DEBUG 2019-09-24 13:13:06,480 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Web.Models.Account.TenantChangeViewModel
DEBUG 2019-09-24 13:13:06,480 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - myapplication.Web.Models.Account.TenantSelectionViewModel+TenantInfo
DEBUG 2019-09-24 13:13:08,736 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.Sessions.ISessionAppService' with service name 'app/session'.
DEBUG 2019-09-24 13:13:08,737 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.Users.IUserAppService' with service name 'app/user'.
DEBUG 2019-09-24 13:13:08,738 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.Roles.IRoleAppService' with service name 'app/role'.
DEBUG 2019-09-24 13:13:08,739 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.MultiTenancy.ITenantAppService' with service name 'app/tenant'.
DEBUG 2019-09-24 13:13:08,740 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.Configuration.IConfigurationAppService' with service name 'app/configuration'.
DEBUG 2019-09-24 13:13:08,741 [1    ] Abp.Logging.LogHelper                    - Dynamic web api controller is created for type 'myapplication.Authorization.Accounts.IAccountAppService' with service name 'app/account'.
WARN  2019-09-24 13:13:26,032 [6    ] Abp.Logging.LogHelper                    - Abp.Authorization.AbpAuthorizationException: Current user did not login to the application!
   at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.AuthorizationHelper.<CheckPermissions>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Abp.Authorization.AuthorizationHelperExtensions.Authorize(IAuthorizationHelper authorizationHelper, MethodInfo methodInfo, Type type)
   at Abp.Web.Mvc.Authorization.AbpMvcAuthorizeFilter.OnAuthorization(AuthorizationContext filterContext)
Abp.Authorization.AbpAuthorizationException: Current user did not login to the application!
   at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.AuthorizationHelper.<CheckPermissions>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Abp.Authorization.AuthorizationHelperExtensions.Authorize(IAuthorizationHelper authorizationHelper, MethodInfo methodInfo, Type type)
   at Abp.Web.Mvc.Authorization.AbpMvcAuthorizeFilter.OnAuthorization(AuthorizationContext filterContext)
DEBUG 2019-09-24 13:15:15,987 [12   ] Abp.Web.SignalR.Hubs.AbpCommonHub        - A client is connected: {"ConnectionId":"93594c5a-5aa2-40be-af8e-c3487535bd12","IpAddress":"192.168.42.1","TenantId":null,"UserId":1,"ConnectTime":"2019-09-24T13:15:15.9774976-06:00","Properties":{}}
DEBUG 2019-09-24 13:15:16,020 [6    ] Abp.Web.SignalR.Hubs.AbpCommonHub        - A client is registered: 93594c5a-5aa2-40be-af8e-c3487535bd12
DEBUG 2019-09-24 13:15:28,150 [10   ] Abp.Web.SignalR.Hubs.AbpCommonHub        - A client is disconnected: 93594c5a-5aa2-40be-af8e-c3487535bd12
DEBUG 2019-09-24 13:15:30,882 [12   ] Abp.Web.SignalR.Hubs.AbpCommonHub        - A client is connected: {"ConnectionId":"e9afe71e-bc64-4c18-a66c-a7381fae6701","IpAddress":"192.168.42.1","TenantId":null,"UserId":1,"ConnectTime":"2019-09-24T13:15:30.8823332-06:00","Properties":{}}
DEBUG 2019-09-24 13:15:30,889 [6    ] Abp.Web.SignalR.Hubs.AbpCommonHub        - A client is registered: e9afe71e-bc64-4c18-a66c-a7381fae6701
WARN  2019-09-24 13:15:35,697 [9    ] naries.DictionaryBasedLocalizationSource - Can not find 'EditTenant' in localization source 'myapplication'!

我想知道免费版本是否不能从头开始运行,我一直在寻找这样的错误,但每个人似乎都能正常运行,并且在他们开始更改代码后遇到问题。

我在调试时没有收到错误的原因是发生在 javascript-ajax 调用,jquery.js 函数:

jQuery.parseJSON = function( data ) {
    return JSON.parse( data + "" );
};

正在接收数据参数:

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
    <h4 class="modal-title">
        <span>Change tenant</span>
    </h4>
</div>

<div class="modal-body">
    <form name="TenantChangeForm" role="form" novalidate class="form-validation">
        <div class="form-group form-float">
            <div class="form-line">
                <input class="form-control" type="text" name="TenancyName" maxlength="64">
                <label class="form-label">Tenancy name</label>
            </div>
        </div>
        <span class="help-block">Leave empty to switch to the host</span>
    </form>
</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default close-button waves-effect" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary save-button waves-effect">Save</button>
</div>

<script src="/Views/Account/_TenantChangeModal.js" type="text/javascript"></script> 

给出错误: SyntaxError: Unexpected token < in JSON at position 0.

和 returns 到 abp.jquery.js :

 }).fail(function (jqXHR) {
              if (jqXHR.responseJSON && jqXHR.responseJSON.__abp) {
                abp.ajax.handleResponse(jqXHR.responseJSON, userOptions, $dfd, jqXHR);
              } else {
                abp.ajax.handleNonAbpErrorResponse(jqXHR, userOptions, $dfd);
              }

我一直在寻找,所有模态都不会显示,所有视图都包含一个 JS 来显示,如下所示:

(function () {
    $('.tenant-change-component a')
        .click(function (e) {
            e.preventDefault();
            abp.ajax({
                url: abp.appPath + 'Account/TenantChangeModal',
                type: 'POST',
                contentType: 'application/html',
                success: function (content) {
                    $('#TenantChangeModal div.modal-content').html(content);
                },
                error: function (e) { }
            });
        });
})();

问题与模式有关,但仅在更改租户和编辑租户时发生,如果我尝试创建租户或用户,它会起作用。

在转到 JSON.Parse 并接收整个视图作为参数后,它收到一个解析器错误,并且:jqXHR.status 获取状态 200。

向数据变量添加了一个 Watch,并且由于参数保持为 null,所以工作的模态永远不会获取整个视图。尝试将函数修改为始终 return null 但屏幕只会变暗。

也尝试更新jquery.js到2.2.4(3以下),因为模板使用的是2.2.0。还是一样的问题。

我在 GitHub 上发布了问题: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4889

通过对触发模态的视图的 Index.js(或 Default.js)进行一些更改来解决此问题:

Replace: $.ajax({

With: abp.ajax({

Replace: contentType: 'application/html',

With: dataType: 'html',

提交: https://github.com/aspnetboilerplate/module-zero-template/pull/169/commits/9105e33b327b6885a0e1aafbd20d7ff092860646

代表提问者添加。