问题
I am using the Finbuckle Multitenant Library and I have encountered an issue with routing to Areas in my Views when I try to do ajax calls.
private static void ConfigRoutes(Microsoft.AspNetCore.Routing.IRouteBuilder routes)
{
routes.MapRoute("Login", "Login", new { controller = "Account", action = "Login", area="Identity"});
routes.MapRoute("Default", "{__tenant__=}/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute("AreaGeneric", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute("Area", "{__tenant__=}/{area:exists}/{controller=Home}/{action=Index}/{id?}");
}
These are the routeMaps that a defined in my Startup.cs
<script>
$(document).ready(function(e){
$.ajax({
url: "@Url.Action("Preview", "Account",new { area="Identity"})",
success: function (result) {
$("#user-container").empty();
var url = "@Url.Action("Index","Manage",new { area="Identity"})";
$("#user-container").append($('<a href="' + url+'"><h5>Welcome, ' + result.UserDetails.FirstName + " " + result.UserDetails.LastName +'</h5></a>'));
}
});
});
</script>
This is the ajax script that is having the issue. The url always reads as
https://localhost:44311/TenantOne/Account/Preview?area=Identity
instead of
https://localhost:44311/TenantOne/Identity/Account/Preview
What can I do to solve this? I'm not sure that I missed anything in my routing.
来源:https://stackoverflow.com/questions/59153320/net-core-multitenancy-causing-area-routing-in-ajax-to-not-work