0

I developed an automation C# WinFormsApp which task is only to check website http statuses from my IIS server and if a website returns an error like error: 500-504, it will restart the Site in IIS and the error should be fixed due to the IIS reset.

Is there any way of simulating/forcefully return errors like 503 or something from my site/IIS server so that I could test if resetting IIS Site really fixed the Site error?

SpiderW3B
  • 43
  • 9
  • This IIS site you're hitting - it's ASP.NET? If so, you should just be able to throw an exception from your site code. – mason Sep 18 '19 at 14:15
  • For now, I'm testing with just local test sites (HTML, CSS) hosted in IIS. -- The final app will be deployed within our company to self heal (resetting in IIS) Site's that encountered server errors. – SpiderW3B Sep 18 '19 at 14:25
  • 1
    You know that just because a site throws a 500 doesn't mean the site needs to be restarted, right? 500 errors can happen for all sorts of different reasons on the server side - and restarting may not even fix them. In fact, I'd guess that *most* 500 errors won't be fixed by restarting the site. – mason Sep 18 '19 at 14:39
  • This question in its current state cannot be answered. If you have control of that site, then its page can return any status code you like at any time you want. If you don't have control of that site, then there isn't much to discuss as you need the actual error to happen. – Lex Li Sep 18 '19 at 16:48
  • @mason Yes I understand. Thanks for the insight however my app just simply "attempts" i thing is the right term, to try and fix the 500 error. If not the app will just log the event and send an email wo our administrators regarding the error. It's like our own httpstatus site monitoring but with an attempt to fix using rest. But thanka to you guys for all of your insights, learned so many things today since im new to IIS. Will be closing this question soon. – SpiderW3B Sep 19 '19 at 15:14
  • Your attempts are going to cause more harm than good. Imagine if you're using the site, then it goes down because *someone else* got a transient error. That's not proper monitoring. Identify what can go wrong with your app, such as connectivity to web API's it might call, or databases. Create a status page that when you hit it, checks those things to make sure they're working. Then have your monitoring app hit that status page. If it's unavailable, send a notification to appropriate people. See https://learn.microsoft.com/en-us/azure/architecture/patterns/health-endpoint-monitoring – mason Sep 19 '19 at 15:16
  • Oh, that's something to note down, got it. Sorry if I really sound like a noob to all of these server stuff. I really appreciate your answers – SpiderW3B Sep 19 '19 at 15:19

0 Answers0