コード例 #1
0
        public virtual Task ProcessRequestAsync(HttpContextBase context)
        {
            var operationName = this.RequestName ?? context.Request.GetOperationName();

            RememberLastRequestInfo(operationName, context.Request.PathInfo);

            if (string.IsNullOrEmpty(operationName))
            {
                return(TypeConstants.EmptyTask);
            }

            if (DefaultHandledRequest(context))
            {
                return(TypeConstants.EmptyTask);
            }

            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, operationName);

            if (RunAsAsync())
            {
                return(ProcessRequestAsync(httpReq, httpReq.Response, operationName));
            }

            return(CreateProcessRequestTask(httpReq, httpReq.Response, operationName));
        }
コード例 #2
0
        // Entry point for ASP.NET
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            var httpContext = context.Request.RequestContext.HttpContext;
            var httpReq     = new ServiceStack.Host.AspNet.AspNetRequest(httpContext, url.SanitizedVirtualPath())
            {
                PhysicalPath = pathTranslated
            };

            return(GetHandler(httpReq));
        }
コード例 #3
0
        public virtual Task ProcessRequestAsync(HttpContextBase context)
        {
            var operationName = this.RequestName ?? context.Request.GetOperationName();

            RememberLastRequestInfo(operationName, context.Request.PathInfo);

            if (string.IsNullOrEmpty(operationName)) return TypeConstants.EmptyTask;

            if (DefaultHandledRequest(context)) return TypeConstants.EmptyTask;

            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, operationName);

            if (RunAsAsync())
                return ProcessRequestAsync(httpReq, httpReq.Response, operationName);

            return CreateProcessRequestTask(httpReq, httpReq.Response, operationName);
        }
コード例 #4
0
        public virtual void ProcessRequest(HttpContextBase context)
        {
            var operationName = this.RequestName ?? context.Request.GetOperationName();

            if (string.IsNullOrEmpty(operationName))
            {
                return;
            }

            if (DefaultHandledRequest(context))
            {
                return;
            }

            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, operationName);

            ProcessRequest(httpReq, httpReq.Response, operationName);
        }
コード例 #5
0
        // Entry point for ASP.NET
        public IHttpHandler GetHandler(HttpContext ctx, string requestType, string url, string pathTranslated)
        {
            var context = ctx.Request.RequestContext.HttpContext;
            var appHost = HostContext.AppHost;

            DebugLastHandlerArgs = requestType + "|" + url + "|" + pathTranslated;
            //var httpReq = new AspNetRequest(context, url);
            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, url.SanitizedVirtualPath());

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

            var mode     = appHost.Config.HandlerFactoryPath;
            var pathInfo = context.Request.GetPathInfo();

            //WebDev Server auto requests '/default.aspx' so recorrect path to different default document
            if (mode == null && (url == "/default.aspx" || url == "/Default.aspx"))
            {
                pathInfo = "/";
            }

            //Default Request /
            if (string.IsNullOrEmpty(pathInfo) || pathInfo == "/")
            {
                //If the fallback route can handle it, let it
                if (appHost.Config.FallbackRestPath != null)
                {
                    string contentType;
                    var    sanitizedPath = RestHandler.GetSanitizedPathInfo(pathInfo, out contentType);

                    var restPath = appHost.Config.FallbackRestPath(context.Request.HttpMethod, sanitizedPath, pathTranslated);
                    if (restPath != null)
                    {
                        return(new RestHandler {
                            RestPath = restPath, RequestName = restPath.RequestType.GetOperationName(), ResponseContentType = contentType
                        });
                    }
                }

                //e.g. CatchAllHandler to Process Markdown files
                var catchAllHandler = GetCatchAllHandlerIfAny(httpReq.HttpMethod, pathInfo, httpReq.GetPhysicalPath());
                if (catchAllHandler != null)
                {
                    return(catchAllHandler);
                }

                if (mode == null)
                {
                    return(DefaultHttpHandler);
                }

                if (DefaultRootFileName != null)
                {
                    return(StaticFilesHandler);
                }

                return(NonRootModeDefaultHttpHandler);
            }

            if (mode != null && pathInfo.EndsWith("/" + mode))
            {
                return(ReturnDefaultHandler(httpReq));
            }

            return(GetHandlerForPathInfo(
                       httpReq.HttpMethod, pathInfo, context.Request.FilePath, pathTranslated)
                   ?? NotFoundHttpHandler);
        }
コード例 #6
0
        public virtual void ProcessRequest(HttpContextBase context)
        {
            var operationName = this.RequestName ?? context.Request.GetOperationName();

            if (string.IsNullOrEmpty(operationName)) return;

            if (DefaultHandledRequest(context)) return;

            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, operationName);

            ProcessRequest(httpReq, httpReq.Response, operationName);
        }
コード例 #7
0
        // Entry point for ASP.NET
        public IHttpHandler GetHandler(HttpContext ctx, string requestType, string url, string pathTranslated)
        {
            var context = ctx.Request.RequestContext.HttpContext;
            var appHost = HostContext.AppHost;

            DebugLastHandlerArgs = requestType + "|" + url + "|" + pathTranslated;
            //var httpReq = new AspNetRequest(context, url);
            var httpReq = new ServiceStack.Host.AspNet.AspNetRequest(context, url.SanitizedVirtualPath());
            foreach (var rawHttpHandler in appHost.RawHttpHandlers)
            {
                var reqInfo = rawHttpHandler(httpReq);
                if (reqInfo != null) return reqInfo;
            }

            var mode = appHost.Config.HandlerFactoryPath;
            var pathInfo = context.Request.GetPathInfo();

            //WebDev Server auto requests '/default.aspx' so recorrect path to different default document
            if (mode == null && (url == "/default.aspx" || url == "/Default.aspx"))
                pathInfo = "/";

            //Default Request /
            if (string.IsNullOrEmpty(pathInfo) || pathInfo == "/")
            {
                //If the fallback route can handle it, let it
                if (appHost.Config.FallbackRestPath != null)
                {
                    string contentType;
                    var sanitizedPath = RestHandler.GetSanitizedPathInfo(pathInfo, out contentType);

                    var restPath = appHost.Config.FallbackRestPath(context.Request.HttpMethod, sanitizedPath, pathTranslated);
                    if (restPath != null)
                    {
                        return new RestHandler { RestPath = restPath, RequestName = restPath.RequestType.GetOperationName(), ResponseContentType = contentType };
                    }
                }

                //Exception calling context.Request.Url on Apache+mod_mono
                var absoluteUrl = Env.IsMono ? url.ToParentPath() : context.Request.GetApplicationUrl();
                SetApplicationBaseUrl(absoluteUrl);

                //e.g. CatchAllHandler to Process Markdown files
                var catchAllHandler = GetCatchAllHandlerIfAny(httpReq.HttpMethod, pathInfo, httpReq.GetPhysicalPath());
                if (catchAllHandler != null) return catchAllHandler;

                if (mode == null)
                    return DefaultHttpHandler;

                if (DefaultRootFileName != null)
                    return StaticFilesHandler;

                return NonRootModeDefaultHttpHandler;
            }

            if (mode != null && pathInfo.EndsWith("/" + mode))
            {
                return ReturnDefaultHandler(httpReq);
            }

            return GetHandlerForPathInfo(
                httpReq.HttpMethod, pathInfo, context.Request.FilePath, pathTranslated)
                   ?? NotFoundHttpHandler;
        }