MVC controller is being called twice

后端 未结 16 652
无人及你
无人及你 2020-11-27 05:15

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

16条回答
  •  执念已碎
    2020-11-27 05:53

    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.

提交回复
热议问题