Base solution for your next web application

Activities of "DennisAhlin"

I solved it by adding Nuget dependency to System.Net.Http 4.3.1 explicitly in .Application, .Core and .Web.Core projects.

Hi! When using domain resolved tenants, the website root address setting have incosistent behaviour.

If I have: server at: <a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a> angular ui at: <a class="postlink" href="http://tenant.mydomain.com">http://tenant.mydomain.com</a>

When server is trying to figure out which tenant is enabled, it uses the host address (<a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a>) here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/850fbe6d851ccdb906c05f77d88b4003de6e1d5c/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs#L41">https://github.com/aspnetboilerplate/as ... tor.cs#L41</a> and compares it to the _multiTenancyConfiguration.DomainFormat, which is App:WebSiteRootAddress setting, so App:WebSiteRootAddress needs to be set to the format of the host (http://{TENANCY_NAME}.api.mydomain.com).

However, when an activation mail is sent when creating a tenant here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/1ead91936c496521e171f3fdf70d129bee021ff2/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Url/AppUrlServiceBase.cs#L34">https://github.com/aspnetzero/aspnet-ze ... ase.cs#L34</a> , the activation link uses WebUrlService.GetSiteRootAddress, which is also the App:WebSiteRootAddress setting. This leads to the activation link becomes <a class="postlink" href="http://tenant.api.mydomain.com/route">http://tenant.api.mydomain.com/route</a>, which is wrong. It should be <a class="postlink" href="http://tenant.mydomain.com/route">http://tenant.mydomain.com/route</a>, otherwise the link doesn't work.

Maybe separate WebSiteRootAddress into two settings? And also name them more clearly (ClientRootAddressFormat/HostRootAddressFormat)?

As a side note, when having the setting without the trailing slash as workaround for previous tenant domain resolver bug, the activation link misses slash between root and relative path (<a class="postlink" href="http://tenant.api.mydomain.comroute">http://tenant.api.mydomain.comroute</a>). I think the url in AppUrlService base should be concatenated in some way that is not sensitive to having a trailing slash or not.

@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?

Answer

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.

Hi! For some reason, register tenant doesn't work in my .NET Core solution. Not from Swagger nor angular ui. It does not reach my breakpoint on first line of TenantRegistrationAppService/RegisterTenant method but returns 500 response code. Other endpoints, like Account/Register works as expected.

Here is my swagger post: <a class="postlink" href="https://www.dropbox.com/s/brh6bqpuppo6mde/Sk%C3%A4rmklipp%202017-03-21%2012.30.51.png">https://www.dropbox.com/s/brh6bqpuppo6m ... .30.51.png</a>

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!

Yes, I restarted the app, dropped the entire database, redeployed it and emptied all cache in the host admin interface. Hopefully the setting shouldn't be trailing somewhere.

I can go to all <a class="postlink" href="http://tenant1.api.staging.mydomain.com">http://tenant1.api.staging.mydomain.com</a>, <a class="postlink" href="http://default.api.staging.mydomain.com">http://default.api.staging.mydomain.com</a> and <a class="postlink" href="http://api.staging.mydomain.com">http://api.staging.mydomain.com</a> and see the Swagger interface.

Ok, I will try with IIS solution locally.

I did have a bad config value in WebSiteRootAddress. It was http://{TENANCY_NAME}.staging.mydomain.com and I have now changed to http://{TENANCY_NAME}.api.staging.mydomain.com. It did no difference, though. I can't go to any other tenant either, like tenant1.staging.mydomain.com. I get the same error modal there even though the first <a class="postlink" href="http://tenant1.api.staging.mydomain.com/AbpUserConfiguration/GetAll">http://tenant1.api.staging.mydomain.com ... ion/GetAll</a> OPTIONS request gets a 204 response.

Showing 21 to 30 of 34 entries