Created
May 2, 2019 11:34
-
-
Save JanneMattila/c24a9ee1f99fd86c88593a7efd4fe682 to your computer and use it in GitHub Desktop.
Stock Web Application and example controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.ApplicationInsights; | |
using System; | |
using System.Diagnostics; | |
using System.Net.Http; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Web.Mvc; | |
namespace StockWebApp.Controllers | |
{ | |
public class ErrorsController : Controller | |
{ | |
private static int _request; | |
private static int _magicalNumber = 0; | |
public ActionResult Index() | |
{ | |
return View(); | |
} | |
public ActionResult Random() | |
{ | |
Interlocked.Increment(ref _request); | |
if (_request > 100) | |
{ | |
_request = 0; | |
// The world best algorithm in action! | |
_magicalNumber = 0; | |
for (int i = 0; i < 10; i++) | |
{ | |
for (int j = i; j < 20; j++) | |
{ | |
if (i % 3 == 0) | |
{ | |
_magicalNumber++; | |
} | |
else if (j < 4) | |
{ | |
_magicalNumber--; | |
} | |
} | |
} | |
// We're exploding but who knows the value of "magicalNumber"? | |
throw new ApplicationException("This is random issue"); | |
} | |
return View(_magicalNumber); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment