gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:53:43 24 4
gpt4 key购买 nike

我正在尝试使用 AspBoilerPlate 作为框架,因为它看起来非常好,而且我一直很难尝试在 Owin Identity 上实现 Multi-Tenancy (几天前我发布了一个问题:Asp.Net Identity Multitenant

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

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

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

它可以工作,但会出现我上面描述的错误。

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

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 atposition 0.

并返回 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);
}

我一直在寻找,所有模态框都不会显示,并且所有 View 都包含一个 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 并接收整个 View 作为参数后,它会出现解析器错误,并且:jqXHR.status 获取状态 200。

向数据变量添加了一个监视,并且使用有效的模式永远不会获得整个 View ,因为参数保持为空。尝试修改函数以始终返回 null,但屏幕只会变暗。

还尝试将jquery.js更新到2.2.4(下面3),因为模板使用2.2.0。仍然是同样的问题。

最佳答案

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

通过对触发模式的 View 的 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

代表提问者添加。

关于javascript - 修复 aspnetboilerplate 启动模板、租户或编辑错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58087212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com