Пример #1
0
        private async Task ProcessElamhRequest(HttpContext context)
        {
            try
            {
                var resource = context.Request.Path.Value.Split('/').LastOrDefault();
                switch (resource)
                {
                case "detail":
                    await ProcessTemplate <ErrorDetailPage>(context, _errorLog);

                    break;

                case "html":
                    break;

                case "xml":
                    ErrorXmlHandler.ProcessRequest(context, _errorLog);
                    break;

                case "json":
                    ErrorJsonHandler.ProcessRequest(context, _errorLog);
                    break;

                case "rss":
                    await ErrorRssHandler.ProcessRequest(context, _errorLog, _elmahRoot);

                    break;

                case "digestrss":
                    await ErrorDigestRssHandler.ProcessRequest(context, _errorLog, _elmahRoot);

                    return;

                case "download":
                    await ErrorLogDownloadHandler.ProcessRequestAsync(_errorLog, context);

                    return;

                case "stylesheet":
                    StyleSheetHelper.LoadStyleSheets(context, StyleSheetHelper.StyleSheetResourceNames, "text/css",
                                                     Encoding.UTF8,
                                                     true);
                    break;

                case "test":
                    throw new TestException();

                case "about":
                    await ProcessTemplate <AboutPage>(context, _errorLog);

                    break;

                default:
                    await ProcessTemplate <ErrorLogPage>(context, _errorLog);

                    break;
                }
            }
            catch (TestException)
            {
                throw;
            }
            catch (Exception)
            {
                _logger.LogError("Elmah request processing error");
            }
        }
Пример #2
0
        private async Task ProcessElmahRequest(HttpContext context, string resource)
        {
            try
            {
                if (resource.StartsWith("api/"))
                {
                    await ErrorApiHandler.ProcessRequest(context, _errorLog, resource);

                    return;
                }

                if (resource.StartsWith("exception/"))
                {
                    await MsdnHandler.ProcessRequestException(context, resource.Substring("exception/".Length));

                    return;
                }

                if (resource.StartsWith("status/"))
                {
                    await MsdnHandler.ProcessRequestStatus(context, resource.Substring("status/".Length));

                    return;
                }

                switch (resource)
                {
                case "xml":
                    await ErrorXmlHandler.ProcessRequest(context, _errorLog);

                    break;

                case "json":
                    await ErrorJsonHandler.ProcessRequest(context, _errorLog);

                    break;

                case "rss":
                    await ErrorRssHandler.ProcessRequest(context, _errorLog, _elmahRoot);

                    break;

                case "digestrss":
                    await ErrorDigestRssHandler.ProcessRequest(context, _errorLog, _elmahRoot);

                    return;

                case "download":
                    await ErrorLogDownloadHandler.ProcessRequestAsync(_errorLog, context);

                    return;

                case "test":
                    throw new TestException();

                default:
                    await ErrorResourceHandler.ProcessRequest(context, resource, _elmahRoot);

                    break;
                }
            }
            catch (TestException)
            {
                throw;
            }
            catch (Exception)
            {
                _logger.LogError("Elmah request processing error");
            }
        }