public void exceptionHandledBehavior(Action <IActionBehavior> behaviorAction)
        {
            if (InsideBehavior == null)
            {
                return;
            }

            try
            {
                behaviorAction(InsideBehavior);
            }
            catch (Exception exception)
            {
                _logger.LogError("An API action threw an exception.", exception);

                if (!AspNetSettings.IsCustomErrorsEnabled || _requestData.IsAjaxRequest())
                {
                    throw;
                }

                var request = new T {
                    Exception = exception
                };
                _request.Set(request);

                _fubuPartialService.Invoke(typeof(T));

                _writer.WriteResponseCode(HttpStatusCode.InternalServerError);
            }
        }
Пример #2
0
        public FubuContinuation Handle()
        {
            if (_requestData.IsAjaxRequest())
            {
                return(FubuContinuation.EndWithStatusCode(HttpStatusCode.Forbidden));
            }

            //ICK - working around Fubu Url building bug
            //var loginUrl = _urlRegistry.UrlFor(new SignInRequest {ReturnUrl = _currentHttpRequest.RawUrl()}); //this is what it should be

            //redirect to login url
            var loginUrl = _urlRegistry.UrlFor(new SignInRequest());

            loginUrl = loginUrl.TrimEnd('/') + "?ReturnUrl=" + _currentHttpRequest.RawUrl().UrlEncode();

            return(FubuContinuation.RedirectTo(loginUrl, categoryOrHttpMethod: null));
        }
Пример #3
0
        public void Write(object output)
        {
            string rawJsonOutput = JsonUtil.ToJson(output);

            if (_requestData.IsAjaxRequest())
            {
                _outputWriter.Write(MimeType.Json.ToString(), rawJsonOutput);
            }
            else
            {
                // For proper jquery.form plugin support of file uploads
                // See the discussion on the File Uploads sample at http://malsup.com/jquery/form/#code-samples
                string html = "<html><body><textarea rows=\"10\" cols=\"80\">" + rawJsonOutput +
                              "</textarea></body></html>";
                _outputWriter.Write(MimeType.Html.ToString(), html);
            }
        }
        public void Handle()
        {
            if (_requestData.IsAjaxRequest())
            {
                _writer.WriteResponseCode(HttpStatusCode.Forbidden);
                return;
            }

            //ICK - working around Fubu Url building bug
            //var loginUrl = _urlRegistry.UrlFor(new SignInRequest {ReturnUrl = _currentHttpRequest.RawUrl()}); //this is what it should be

            //redirect to login url
            var loginUrl = _urlRegistry.UrlFor(new SignInRequest());

            loginUrl = loginUrl.TrimEnd('/') + "?ReturnUrl=" + _currentHttpRequest.RawUrl().UrlEncode();

            _writer.RedirectToUrl(loginUrl);
        }
 public bool Applies()
 {
     return(_data.IsAjaxRequest());
 }