Exemple #1
0
        public MvcErrorLog(string application, ExceptionContext exceptionContext) : base(application, exceptionContext.Exception)
        {
            var context = exceptionContext.HttpContext;

            if (context == null)
            {
                return;
            }

            Host = Host ?? TryGetMachineName(context);

            var user = context.User;

            if (!(user == null || string.IsNullOrWhiteSpace(user.Identity.Name)))
            {
                User = user.Identity.Name;
            }

            var request = context.Request;

            ServerVariables.Add(request.ServerVariables);
            QueryString.Add(request.QueryString);
            Form.Add(request.Form);
            Cookies.Add(request.Cookies);
        }
        public void CancelChanges()
        {
            if (Element == null)
            {
                return;
            }

            Name           = (string)Element["name"];
            Enabled        = (bool)Element["enabled"];
            PatternSyntax  = (long)Element["patternSyntax"];
            StopProcessing = (bool)Element["stopProcessing"];
            ConfigurationElement matchElement = Element.ChildElements["match"];

            PatternUrl = (string)matchElement["url"];
            Negate     = (bool)matchElement["negate"];
            ConfigurationElement actionElement = Element.ChildElements["action"];

            Type              = (long)actionElement["type"];
            ActionUrl         = (string)actionElement["url"];
            AppendQueryString = (bool)actionElement["appendQueryString"];
            LogRewrittenUrl   = (bool)actionElement["logRewrittenUrl"];
            var redirect = (long)actionElement["redirectType"];

            switch (redirect)
            {
            case 301:
                RedirectType = 0;
                break;

            case 302:
                RedirectType = 1;
                break;

            case 303:
                RedirectType = 2;
                break;

            case 307:
                RedirectType = 3;
                break;
            }

            StatusCode        = (uint)actionElement["statusCode"];
            SubStatusCode     = (uint)actionElement["subStatusCode"];
            StatusReason      = (string)actionElement["statusReason"];
            StatusDescription = (string)actionElement["statusDescription"];

            var conditions = Element.ChildElements["conditions"];

            TrackAllCaptures = (bool)conditions["trackAllCaptures"];
            LogicalGrouping  = (long)conditions["logicalGrouping"];

            foreach (ConfigurationElement condition in conditions.GetCollection())
            {
                var item = new ConditionItem(condition);
                Conditions.Add(item);
            }

            var variables = Element.ChildElements["serverVariables"];

            foreach (ConfigurationElement variable in variables.GetCollection())
            {
                var item = new ServerVariableItem(variable);
                ServerVariables.Add(item);
            }
        }
 public FakeHttpRequest WithQueryString(string value)
 {
     ServerVariables.Add(QueryStringVariable, value);
     return(this);
 }