I have hosted a new ASP.Net core application as a sub-site of another application in IIS. In local everything has been working fine. But, after publishing this application as a subsite, Ajax post request is hitting the wrong controller and action.
Using Ajax to call the BGetDetails action in BController. But the request is hitting on the AGetDetails action in AController.
I have tried a lot of ways to fix this issue, but can't do it.
If hosted this application as a separate domain everything has been fine. I have to face the issue only when hosting the application as a sub-site of another application.
I have attached the same codes. Please find those below,
Route config
app.UseMvc(routes =>
{
routes.MapRoute(
name: "yyyyyyy",
template: "Platform/GetDetails",
defaults: new { controller = "B", action = "BGetDetails" });
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "xxxxxx",
template: "{arug1}/{arug2}",
defaults: new { controller = "A", action = "AGetDetails" });
});
Ajax call:
data = { "arug1": arug1, "arug2": arug2, "arug3": arug3, "arug4": arug4, "arug5": arug5 };
$.ajax({
type: "POST",
url: "/sub-site/Platform/GetDetails",
data: data,
success: function (result) {
...
}});
Controller:
controller-1
public class AController: Controller
{
[HttpGet]
public ActionResult AGetDetails(string arug1, string arug2)
{
...........
}
}
Controller-2
public class BController : Controller
{
[HttpPost]
public ActionResult BGetDetails(string arug1, string arug2, string arug3, string arug4, bool arug5)
{
.........
}
}
Help me to resolve this issue. Thanks in advance,