コード例 #1
0
ファイル: ScriptModule.cs プロジェクト: dox0/DotNet471RS3
        private static bool ShouldSkipAuthorization(HttpContext context)
        {
            if (context == null || context.Request == null)
            {
                return(false);
            }

            string path = context.Request.FilePath;

            if (ScriptResourceHandler.IsScriptResourceRequest(path))
            {
                return(true);
            }

            // if auth service is disabled, dont bother checking.
            // (NOTE: if a custom webservice is used, it will be up to them to enable anon access to it)
            // if it isn't a rest request dont bother checking.
            if (!ApplicationServiceHelper.AuthenticationServiceEnabled || !RestHandlerFactory.IsRestRequest(context))
            {
                return(false);
            }

            if (context.SkipAuthorization)
            {
                return(true);
            }

            // it may be a rest request to a webservice. It must end in axd if it is an app service.
            if ((path == null) || !path.EndsWith(".axd", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            // WebServiceData caches the object in cache, so this should be a quick lookup.
            // If it hasnt been cached yet, this will cause it to be cached, so later in the request
            // it will be a cache-hit anyway.
            WebServiceData wsd = WebServiceData.GetWebServiceData(context, path, false, false);

            if ((wsd != null) && (_authenticationServiceType == wsd.TypeData.Type))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: ScriptModule.cs プロジェクト: dox0/DotNet471RS3
        private void OnPostAcquireRequestState(object sender, EventArgs eventArgs)
        {
            HttpApplication app     = (HttpApplication)sender;
            HttpRequest     request = app.Context.Request;

            if (app.Context.Handler is Page && RestHandlerFactory.IsRestMethodCall(request))
            {
                // Get the data about the web service being invoked
                WebServiceData webServiceData = WebServiceData.GetWebServiceData(HttpContext.Current, request.FilePath, false, true);

                // Get the method name
                string methodName = request.PathInfo.Substring(1);

                // Get the data about the specific method being called
                WebServiceMethodData methodData = webServiceData.GetMethodData(methodName);
                RestHandler.ExecuteWebServiceCall(HttpContext.Current, methodData);

                // Skip the rest of the page lifecycle
                app.CompleteRequest();
            }
        }