0

I'm new to asp web API and I created a hello world HttpResponseMessage and I'm using postman for testing it, but on the first try, it takes 12385 ms to response.

Is that normal? if it's not then what is the problem?!

 public HttpResponseMessage Get() { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value"); response.Content = new StringContent("Hello world", Encoding.Unicode); response.Headers.CacheControl = new CacheControlHeaderValue() { MaxAge = TimeSpan.FromMinutes(20) }; return response; } 
7
  • Are you running inside Visual Studio? Or deploying to IIS? If running under IIS, there is time devoted to bring up the web application which is definitely noticeable the first time a request is made, but even then a 12 second startup is extremely long. There is nothing with the code that you have shown that would delay the request though so you'd have to give us more info to go on to be able to help. Commented Sep 18, 2018 at 13:56
  • @user1011627 It's running under IIS and this code is the only code in my project Commented Sep 18, 2018 at 14:00
  • If you are deploying to IIS and then testing via Postman, it is "normal" to experience a delay on the first request as IIS has to spin up the app to be able to service the request. Darin does a good job of explaining on this similar SO question. stackoverflow.com/questions/20165670/… Commented Sep 18, 2018 at 14:04
  • @user1011627 just realized something, when IIs is started for first time response time is 1333 ms but after rebuilding, it goes back to 12385 ms Commented Sep 18, 2018 at 14:12
  • It looks to me like you are just running into the typical behavior of IIS. When you "rebuild", it will take the application down and recycle the app pool. Commented Sep 18, 2018 at 14:39

1 Answer 1

1

If you are deploying to IIS and then testing via Postman, it is "normal" to experience a delay on the first request as IIS has to spin up the app to be able to service the request. Darin does a good job of explaining on this similar SO question.

First Web API session request is very slow

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.