I'm using Sitecore 9.1.1, and a multisite setup.
I have a custom controller rendering that I view from a page in Site2, my controller had 2 methods: an Index() method that returns the view, and a Submit() method that does something else (called by ajax)
What happens is, inside my Index method, Sitecore.Context.Site.Name returns "Site2" correctly, however when I debug inside my Submit() method, Sitecore.Context.Site.Name returns "Site1" for some bizarre reason!
I have tried setting a dummy variable with a value and checking what happens inside each of Index() and Submit(), I tried this code:
public string x = "x";
public ActionResult Index()
{
x = "y";
return View();
}
[HttpPost]
public string Submit(exampleModel ex)
{
...
}
It turns out, as soon as my breakpoint inside Submit() is hit, "x" is reset back to its original value, I think Sitecore.Context.Site is being reset as well, I have no idea why this is happening though.
I need to read the Context.Site.Name correctly, does anyone know why this happens or what I did to cause the reset?