Thank you!
I solved it with method 2. I tried with NSwag first, but since it does not generate a base client I was required to make a partial class with the interception for every controller, which is a bit tedious and takes away a part of the benefits of code generation. Therefore I went for Swagger Codegen instead, where I only need to make a partial of the base ApiClient for the interception. It was also easier to solve the authorization part in Codegen.
Just FYI, here you can read more about the implementation of UOW :)
<a class="postlink" href="https://www.aspnetboilerplate.com/Pages/Documents/Unit-Of-Work">https://www.aspnetboilerplate.com/Pages ... it-Of-Work</a>
GitHub issue here: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/109">https://github.com/aspnetzero/aspnet-ze ... issues/109</a>
I solved it like this:
private static loadLocalizedScripts(): JQueryPromise<any> {
if (!abp.session.userId) {
return $.Deferred().resolve();
}
var currentCulture = abp.localization.currentLanguage.name;
var jTable = "/assets/localization/jtable/jquery.jtable.{0}.js";
var bootstrapSelect = "/assets/localization/bootstrap-select/defaults-{0}.js";
var jqueryTimeago = "/assets/localization/jquery-timeago/jquery.timeago.{0}.js";
return $.when(
((currentCulture !== 'en') ? jQuery.getScript(abp.utils.formatString(jTable, LocalizedResourcesHelper.mapCultureForJtable(currentCulture))) : $.Deferred().resolve()),
jQuery.getScript(abp.utils.formatString(bootstrapSelect, LocalizedResourcesHelper.mapCultureForBootstrapSelect(currentCulture))),
jQuery.getScript(abp.utils.formatString(jqueryTimeago, LocalizedResourcesHelper.mapCultureForTimeago(currentCulture)))
);
}
private static mapCultureForJtable(currentCulture: string): string {
const cultureMap = {
'sv-SE': 'se',
'sv': 'se'
//Add more here
};
if (cultureMap[currentCulture])
return cultureMap[currentCulture];
return currentCulture;
}
private static mapCultureForBootstrapSelect(currentCulture: string): string {
const cultureMap = {
'en': 'en_US'
//Add more here
};
if (cultureMap[currentCulture])
return cultureMap[currentCulture];
return currentCulture.replace('-', '_');
}
private static mapCultureForTimeago(currentCulture: string): string {
const cultureMap = {
'sv-SE': 'sv'
//Add more here
};
if (cultureMap[currentCulture])
return cultureMap[currentCulture];
return currentCulture;
}
I solved it by adding Nuget dependency to System.Net.Http 4.3.1 explicitly in .Application, .Core and .Web.Core projects.
@ismcagdas, have you made any progress on this issue? I've tried solving it myself but with no luck. Is there a git issue I can follow to get updates?
I figured out how to setup domain tenant recognition on localhost reasonably simple.
If anyone is interested, answer this thread and I'll write a guide :)
DEBUG 2017-03-21 14:39:51,155 [15 ] Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL3GCTFH9U83" completed keep alive response.
INFO 2017-03-21 14:39:51,155 [15 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 12.0115ms 500
INFO 2017-03-21 14:39:55,430 [14 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://api.staging.project.com/api/services/app/TenantRegistration/RegisterTenant">http://api.staging.project.com/api/serv ... sterTenant</a>
DEBUG 2017-03-21 14:39:55,430 [14 ] Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL3GCTFH9U8A" completed keep alive response.
INFO 2017-03-21 14:39:55,430 [14 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 2.478ms 204
INFO 2017-03-21 14:39:55,508 [9 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST <a class="postlink" href="http://api.staging.project.com/api/services/app/TenantRegistration/RegisterTenant">http://api.staging.project.com/api/serv ... sterTenant</a> application/json; charset=UTF-8 461
DEBUG 2017-03-21 14:39:55,508 [9 ] NetCore.StaticFiles.StaticFileMiddleware - POST requests are not supported
DEBUG 2017-03-21 14:39:55,508 [9 ] osoft.AspNetCore.Routing.Tree.TreeRouter - Request successfully matched the route with name '(null)' and template 'api/services/app/TenantRegistration/RegisterTenant'.
DEBUG 2017-03-21 14:39:55,523 [9 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action project.MultiTenancy.TenantRegistrationAppService.RegisterTenant (project.Application)
DEBUG 2017-03-21 14:39:55,555 [9 ] Mvc.ModelBinding.Binders.BodyModelBinder - Selected input formatter 'Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter' for content type 'application/json; charset=UTF-8'.
INFO 2017-03-21 14:39:55,555 [9 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method project.MultiTenancy.TenantRegistrationAppService.RegisterTenant (project.Application) with arguments (project.MultiTenancy.Dto.RegisterTenantInput) - ModelState is Valid
ERROR 2017-03-21 14:39:55,695 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at System.Net.Http.WinHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at PaulMiami.AspNetCore.Mvc.Recaptcha.RecaptchaService.<ValidateResponseAsync>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 project.Web.Security.Recaptcha.RecaptchaValidator.<ValidateAsync>d__4.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 project.MultiTenancy.TenantRegistrationAppService.<RegisterTenant>d__9.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 Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.<CastToObject>d__40`1.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 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.
Could it be after ABP update?
Try right clicking on your projectname.Migrator project and "Start new instance". You should get a command prompt window where it asks you if you want to migrate to the connection string. Check that the Host database is correct and confirm. If the database is wrong, change the Default ConnectionString in Migrator project to the connection you want.
So, for anyone with the same problem. The error was that the App:WebSiteRootAddress had a trailing slash. Also, currently you have to add every subdomain into App:CorsOrigins with trailing slash.
Thank you Zero for very good support!