I have a controller that is being called twice from an ActionLink call.
My home page has a link, that when clicked calls the Index method on the Play controller. An
I had this same issue and verified all the possible suggestions but no luck then I noticed following JS warning message in my Console.
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
xmlHttp = new XMLHttpRequest();
I corrected this and it works for me.
Take care all your js errors and warning messages.
This may help to someone.
My issue was resolved by making sure I wasn't double referencing my JavaScript
files, which I was.
This was causing the action to be hit twice when I clicked the link.
I know the above has been said before but I thought I would point out that it's worth checking to see if your files are being loaded twice, especially if you're using Partial Views
.
I noticed that in one of my Partial Views
I was telling it to use the main layout page which contained the scripts that were responsible for what happened when I clicked on the links. So I fixed this by just setting layout = null;
since it's a partial view anyway and is already being loaded inside of the main layout.
Is there any other markup that could be accidentally referencing the page? Script references, image references, css references, all could be mistakenly pointed at '.' or the current page.
You can also try changing your route to this.
routes.MapRoute(
"Play", // Route name
"Play/{id}", // URL with parameters
new { controller = "Play", action = "Index" , id = "" } // Parameter defaults
);
there should be a html markeup that is not working properly. please check all img tage. also check
<link rel="icon" href="favicon.ico" type="image/x-icon" />
This is an old question and some answers are still useful. That is why I am adding a new answer, hoping that will help someone else. For me, I have an app that redirects users back and forth between my domains. Due to some of my recent HttpCookie related work, I had added below line of code:
httpCookieObject.SameSite = SameSiteMode.Strict;
Turns out the SameSiteMode.Strict causes issues when it comes to cross-origin authentication schemes. This is Microsoft documentation about it: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-2.2
To strictly enforce a same-site policy of SameSiteMode.Strict, set the MinimumSameSitePolicy. Although this setting breaks OAuth2 and other cross-origin authentication schemes, it elevates the level of cookie security for other types of apps that don't rely on cross-origin request processing.
So, my solution was that I do not use the SameSiteMode.Strict policy and I am good to go.