Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i'm currently working on an already existing project which is written in ASP.NET 5. In this there is a form on which is a button. This button gets pressed many times (up to 400 times within 3 hours approx). Today i made an automated test run for 6 hours in which the button was pressed roughly 1000 times. Suddenly the post method for the form in which the button is placed was not reachable anymore. I'm using Windows Server 2012 with IIS 8. My form looks like this:

@using (Html.BeginForm("PerformanceControl", "Performance"))
{
      //some stuff left out
      <div class="col-md-12 col-sm-12">
             <button name="button" src value="forwardRecord" class="btn btn-primary">
                                  Next Chunk class="fa fa-arrow-circle-right"> 
             </button>
       </div>
}


The receiving post method looks like this:

[HttpPost]
public IActionResult PerformanceControl(int id, string button, ShowPerformanceControlViewModel viewModel)
{//id is projectID
	//Do some stuff
             return RedirectToAction("PerformanceControl");
}


I have left out the logic code because it's a very big method.
The POST and GET method of the performance control are getting called with the same URL pattern: "/Performance/PerformanceControl/11" (the eleven is just an example ID).
The GET version of the call still works when the error occurs. I'm new to ASP.NET so i don't really what could be the reason for this strange behaviour especially when it worked 1000 times in the same session and the session data was not lost. The endpoint was only not reachable anymore?

Update:

I have now managed to recreate the problem and at first i thought it was the POST request but it turns out that the GET request after processing the form data fails, but when i hit reload the site works. Is there a common problem with redirect in ASP.NET?

P.S.: Sorry for my bad englisch, my native language is german.

What I have tried:

I have looked through all the logs of the server the only thing i could find was that after 14:20 (20.06.2018) every post request to post Method of the form didn't work anymore. Every other form on my website e.g. Login and Registration form did still work without a problem. I have also looked through the window event viewer but i could not find any suspicious entries. Only a restart of the asp.net site brought the form back to life. I also checked if there are database errors but there arent.
Posted
Updated 20-Jun-18 9:27am
v2

1 solution

You have already discovered why the redirect is not working: the form method is GET so the POST action will never occur.

Very easy fix, change the method on the form to POST
C#
@using (Html.BeginForm("PerformanceControl", "Performance", FormMethod.Post))
 
Share this answer
 
Comments
Andreas Gosch 20-Jun-18 18:06pm    
Thanks for that, but why is it working about 500 times and then starts to fail? This is just my curiosity.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900