Inheritance: IHttpHandler
Example #1
0
        public virtual IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback callback, object state)
        {
            if (HttpRuntime.UseIntegratedPipeline)
            {
                throw new PlatformNotSupportedException(System.Web.SR.GetString("Method_Not_Supported_By_Iis_Integrated_Mode", new object[] { "DefaultHttpHandler.BeginProcessRequest" }));
            }
            this._context = context;
            HttpResponse response = this._context.Response;

            if (response.CanExecuteUrlForEntireResponse)
            {
                string virtualPath = this.OverrideExecuteUrlPath();
                if (((virtualPath != null) && !HttpRuntime.IsFullTrust) && !base.GetType().Assembly.GlobalAssemblyCache)
                {
                    HttpRuntime.CheckFilePermission(MapPathWithAssert(context, virtualPath));
                }
                return(response.BeginExecuteUrlForEntireResponse(virtualPath, this._executeUrlHeaders, callback, state));
            }
            this.OnExecuteUrlPreconditionFailure();
            this._context = null;
            HttpRequest request = context.Request;

            if (request.HttpVerb == HttpVerb.POST)
            {
                throw new HttpException(0x195, System.Web.SR.GetString("Method_not_allowed", new object[] { request.HttpMethod, request.Path }));
            }
            if (IsClassicAspRequest(request.FilePath))
            {
                throw new HttpException(0x193, System.Web.SR.GetString("Path_forbidden", new object[] { request.Path }));
            }
            StaticFileHandler.ProcessRequestInternal(context, this.OverrideExecuteUrlPath());
            return(new HttpAsyncResult(callback, state, true, null, null));
        }
Example #2
0
        public virtual IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
        {
            // DDB 168193: DefaultHttpHandler is obsolate in integrated mode
            if (HttpRuntime.UseIntegratedPipeline)
            {
                throw new PlatformNotSupportedException(SR.GetString(SR.Method_Not_Supported_By_Iis_Integrated_Mode, "DefaultHttpHandler.BeginProcessRequest"));
            }

            _context = context;
            HttpResponse response = _context.Response;

            if (response.CanExecuteUrlForEntireResponse)
            {
                // use ExecuteUrl
                String path = OverrideExecuteUrlPath();

                if (path != null && !HttpRuntime.IsFullTrust)
                {
                    // validate that an untrusted derived classes (not in GAC)
                    // didn't set the path to a place that CAS wouldn't let it access
                    if (!this.GetType().Assembly.GlobalAssemblyCache)
                    {
                        HttpRuntime.CheckFilePermission(MapPathWithAssert(context, path));
                    }
                }

                return(response.BeginExecuteUrlForEntireResponse(path, _executeUrlHeaders, callback, state));
            }
            else
            {
                // let the base class throw if it doesn't want static files handler
                OnExecuteUrlPreconditionFailure();

                // use static file handler
                _context = null; // don't keep request data alive in sync case

                HttpRequest request = context.Request;

                // refuse POST requests
                if (request.HttpVerb == HttpVerb.POST)
                {
                    throw new HttpException(405, SR.GetString(SR.Method_not_allowed, request.HttpMethod, request.Path));
                }

                // refuse .asp requests
                if (IsClassicAspRequest(request.FilePath))
                {
                    throw new HttpException(403, SR.GetString(SR.Path_forbidden, request.Path));
                }

                // default to static file handler
                StaticFileHandler.ProcessRequestInternal(context, OverrideExecuteUrlPath());

                // return async result indicating completion
                return(new HttpAsyncResult(callback, state, true, null, null));
            }
        }
Example #3
0
        public virtual IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback callback, object state)
        {
            this.Context = context;

            HttpRequest req      = context != null ? context.Request : null;
            string      filePath = req != null ? req.FilePath : null;

            if (!String.IsNullOrEmpty(filePath) && String.Compare(".asp", VirtualPathUtility.GetExtension(filePath), StringComparison.OrdinalIgnoreCase) == 0)
            {
                throw new HttpException(String.Format("Access to file '{0}' is forbidden.", filePath));
            }

            if (req != null && String.Compare("POST", req.HttpMethod, StringComparison.OrdinalIgnoreCase) == 0)
            {
                throw new HttpException(String.Format("Method '{0}' is not allowed when accessing file '{1}'", req.HttpMethod, filePath));
            }

            var sfh = new StaticFileHandler();

            sfh.ProcessRequest(context);

            return(new DefaultHandlerAsyncResult(callback, state));
        }
Example #4
0
		public virtual IAsyncResult BeginProcessRequest (HttpContext context, AsyncCallback callback, object state)
		{
			this.Context = context;

			HttpRequest req = context != null ? context.Request : null;
			string filePath = req != null ? req.FilePath : null;

			if (!String.IsNullOrEmpty (filePath) && String.Compare (".asp", VirtualPathUtility.GetExtension (filePath), StringComparison.OrdinalIgnoreCase) == 0)
				throw new HttpException (String.Format ("Access to file '{0}' is forbidden.", filePath));

			if (req != null && String.Compare ("POST", req.HttpMethod, StringComparison.OrdinalIgnoreCase) == 0)
				throw new HttpException (String.Format ("Method '{0}' is not allowed when accessing file '{1}'", req.HttpMethod, filePath));

			var sfh = new StaticFileHandler ();
			sfh.ProcessRequest (context);
			
			return new DefaultHandlerAsyncResult (callback, state);
		}