public void ProcessRequest(HttpContext context)
        {
            IHttpRequest  request  = new EndpointsExtensions.HttpRequestWrapper(ServicePath, typeof(CustomOperationHandler).Name, context.Request);
            IHttpResponse response = new EndpointsExtensions.HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);
            ProcessRequest(request, response, typeof(CustomOperationHandler).Name);
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;
            var httpReq  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper(_servicePath, typeof(SwaggerApiService).Name, request);
            var httpRes  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            ProcessRequest(httpReq, httpRes, null);
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            //if (_config.UseBasicAuth &&  context.Response.StatusCode == HttpNotAuthorizedStatusCode)
            //{
            //    context.Response.AddHeader(HttpWWWAuthenticateHeader, "Basic realm =\"" + Realm + "\"");
            //}

            var request  = context.Request;
            var response = context.Response;
            var httpReq  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper(_servicePath, typeof(SwaggerResourcesService).Name, request);
            var httpRes  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            ProcessRequest(httpReq, httpRes, null);
        }
예제 #4
0
        // Entry point for ASP.NET
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            DebugLastHandlerArgs = requestType + "|" + url + "|" + pathTranslated;

            var    pathInfo = context.Request.GetPathInfo();
            string servicePath;

            GetServicePathInfo(pathInfo, out servicePath, out pathInfo);

            var httpReq = new HttpRequestWrapper(servicePath, pathTranslated, context.Request);

            foreach (var rawHttpHandler in RawHttpHandlers)
            {
                var reqInfo = rawHttpHandler(httpReq);
                if (reqInfo != null)
                {
                    return(reqInfo);
                }
            }

            var mode = EndpointHost.Config.ServiceStackHandlerFactoryPath;

            if (mode == null && (url == "/default.htm" || url == "Default.htm" || url == "/default.aspx" || url == "/Default.aspx"))
            {
                pathInfo = "/";
            }

            // Redirect to metadata page
            if (string.IsNullOrEmpty(pathInfo) || pathInfo == "/")
            {
                if (EndpointHost.Config.HostMultipleServices && servicePath == ServiceMetadata.EmptyServicePath)
                {
                    return(new MultiServiceMetadataHandler());
                }

                if (IsValidServicePath(servicePath))
                {
                    return(GetRedirectHandler(context.Request.GetApplicationUrl(), servicePath));
                }
            }

            return(GetHandlerForPathInfo(
                       context.Request.HttpMethod, servicePath, pathInfo, context.Request.FilePath, pathTranslated)
                   ?? GetNotFoundHttpHandler(servicePath));
        }
예제 #5
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            var httpReq = new HttpRequestWrapper(_servicePath, "NotFoundHttpHandler", request);
            var httpRes = new HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            if (!request.IsLocal)
            {
                ProcessRequest(httpReq, new HttpResponseWrapper(response), null);
                return;
            }

            Dictionary <string, string> logTags = new Dictionary <string, string>()
            {
                { "ErrorCode", "FXD300013" }
            };

            if (httpReq.UrlReferrer != null && !string.IsNullOrWhiteSpace(httpReq.UrlReferrer.AbsoluteUri))
            {
                logTags["Referer"] = httpReq.UrlReferrer.AbsoluteUri;
            }
            Log.Warn(string.Format("{0} Request not found: {1}", httpReq.RemoteIp, httpReq.RawUrl), logTags);

            var sb = new StringBuilder();

            sb.AppendLine("Handler for Request not found: \n\n");

            sb.AppendLine("Request.ApplicationPath: " + request.ApplicationPath);
            sb.AppendLine("Request.CurrentExecutionFilePath: " + request.CurrentExecutionFilePath);
            sb.AppendLine("Request.FilePath: " + request.FilePath);
            sb.AppendLine("Request.HttpMethod: " + request.HttpMethod);
            sb.AppendLine("Request.MapPath('~'): " + request.MapPath("~"));
            sb.AppendLine("Request.Path: " + request.Path);
            sb.AppendLine("Request.ServicePath: " + _servicePath);
            sb.AppendLine("Request.PathInfo: " + request.PathInfo);
            sb.AppendLine("Request.ResolvedPathInfo: " + httpReq.PathInfo);
            sb.AppendLine("Request.PhysicalPath: " + request.PhysicalPath);
            sb.AppendLine("Request.PhysicalApplicationPath: " + request.PhysicalApplicationPath);
            sb.AppendLine("Request.QueryString: " + request.QueryString);
            sb.AppendLine("Request.RawUrl: " + request.RawUrl);
            sb.AppendLine("Request.Referer: " + (request.UrlReferrer == null ? string.Empty : request.UrlReferrer.AbsoluteUri));
            try
            {
                sb.AppendLine("Request.Url.AbsoluteUri: " + request.Url.AbsoluteUri);
                sb.AppendLine("Request.Url.AbsolutePath: " + request.Url.AbsolutePath);
                sb.AppendLine("Request.Url.Fragment: " + request.Url.Fragment);
                sb.AppendLine("Request.Url.Host: " + request.Url.Host);
                sb.AppendLine("Request.Url.LocalPath: " + request.Url.LocalPath);
                sb.AppendLine("Request.Url.Port: " + request.Url.Port);
                sb.AppendLine("Request.Url.Query: " + request.Url.Query);
                sb.AppendLine("Request.Url.Scheme: " + request.Url.Scheme);
                sb.AppendLine("Request.Url.Segments: " + request.Url.Segments);
            }
            catch (Exception ex)
            {
                sb.AppendLine("Request.Url ERROR: " + ex.Message);
            }
            if (IsIntegratedPipeline.HasValue)
            {
                sb.AppendLine("App.IsIntegratedPipeline: " + IsIntegratedPipeline);
            }
            if (!WebHostPhysicalPath.IsNullOrEmpty())
            {
                sb.AppendLine("App.WebHostPhysicalPath: " + WebHostPhysicalPath);
            }
            if (!ApplicationBaseUrl.IsNullOrEmpty())
            {
                sb.AppendLine("App.ApplicationBaseUrl: " + ApplicationBaseUrl);
            }
            if (!AntServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty())
            {
                sb.AppendLine("App.DebugLastHandlerArgs: " + AntServiceStackHttpHandlerFactory.DebugLastHandlerArgs);
            }

            response.ContentType = "text/plain";
            response.StatusCode  = 404;
            response.EndHttpHandlerRequest(skipClose: true, afterBody: r => r.Write(sb.ToString()));
        }