3

I'm creating an API using ASP.NET Web API 2. Everything looks okay but in some cases, after getting an error 400, all the next requests return that same error 400 reponse even if the requests are different.

If I restart IIS, redeploy the API or just changing one space in web.config, the request works fine until I get another error 400 somewhere and the problem starts again.

It looks the error 400 response is cached somehow...

Did anyone have this problem and know how to fix it?

nano
  • 2,511
  • 4
  • 25
  • 42

2 Answers2

0

I found solutions on stack overflow may b this can help you.

Configure IIS Express

Community
  • 1
  • 1
Amit Guleria
  • 211
  • 2
  • 11
  • The API is already deployed in a server, using IIS. It works fine until I get an error 400 when the rest of the calls return same error no matter what requests are done. Don't see what this answer is related with this. – nano Sep 02 '15 at 11:42
0

I was having a single shared static DbContext instance.

I changed to one instance of DbContext for each of my scopes and got rid of the static DbContext and instead create and dispose of it after each SaveChanges(Async) call.

Now everything works fine. Hope it helps.

nano
  • 2,511
  • 4
  • 25
  • 42