コード例 #1
0
        private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory)
        {
            // If request validation has already been enabled, make it lazy. This allows attributes like [HttpPost] (which looks
            // at Request.Form) to work correctly without triggering full validation.
            // Tolerate null HttpContext for testing.
            HttpContext currentContext = HttpContext.Current;

            if (currentContext != null)
            {
                bool?isRequestValidationEnabled = ValidationUtility.IsValidationEnabled(currentContext);
                if (isRequestValidationEnabled == true)
                {
                    ValidationUtility.EnableDynamicValidation(currentContext);
                }
            }

            AddVersionHeader(httpContext);
            RemoveOptionalRoutingParameters();

            // Get the controller type
            string controllerName = RequestContext.RouteData.GetRequiredString("controller");

            // Instantiate the controller and call Execute
            factory    = ControllerBuilder.GetControllerFactory();
            controller = factory.CreateController(RequestContext, controllerName);
            if (controller == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              MvcResources.ControllerBuilder_FactoryReturnedNull,
                              factory.GetType(),
                              controllerName));
            }
        }
コード例 #2
0
        internal void ProcessRequestInternal(HttpContext context)
        {
            // enable dynamic validation for this request
            ValidationUtility.EnableDynamicValidation(context);
            context.Request.ValidateInput();

            try {
                HttpContextBase contextBase = new HttpContextWrapper(context);
                //WebSecurity.Context = contextBase;
                AddVersionHeader(contextBase);

                WebPageRenderingBase startPage = StartPage.GetStartPage(_webPage, StartPageFileName, WebPageHttpHandler.GetRegisteredExtensions());

                // This is also the point where a Plan9 request truly begins execution

                // We call ExecutePageHierarchy on the requested page, passing in the possible initPage, so that
                // the requested page can take care of the necessary push/pop context and trigger the call to
                // the initPage.
                _webPage.ExecutePageHierarchy(Util.CreatePageContext(context), context.Response.Output, startPage);

                if (ShouldGenerateSourceHeader(contextBase))
                {
                    GenerateSourceFilesHeader(_webPage.PageContext);
                }
            }
            catch (Exception e) {
                if (!HandleError(e))
                {
                    throw;
                }
            }
        }
コード例 #3
0
        internal void ProcessRequestInternal(HttpContext context)
        {
            // enable dynamic validation for this request
            ValidationUtility.EnableDynamicValidation(context);
            context.Request.ValidateInput();

            HttpContextBase contextBase = new HttpContextWrapper(context);

            ProcessRequestInternal(contextBase);
        }
コード例 #4
0
        /// <remarks>
        /// Copied from: System.Web.Mvc.ControllerActionInvoker
        /// </remarks>
        private static void ValidateRequest(ControllerContext controllerContext)
        {
            if (controllerContext.IsChildAction)
            {
                return;
            }

            // Tolerate null HttpContext for testing
            HttpContext currentContext = HttpContext.Current;

            if (currentContext != null)
            {
                ValidationUtility.EnableDynamicValidation(currentContext);
            }

            controllerContext.HttpContext.Request.ValidateInput();
        }
コード例 #5
0
        internal static void ValidateRequest(ControllerContext controllerContext)
        {
            if (controllerContext.IsChildAction)
            {
                return;
            }

            // DevDiv 214040: Enable Request Validation by default for all controller requests
            //
            // Earlier versions of this method dereferenced Request.RawUrl to force validation of
            // that field. This was necessary for Routing before ASP.NET v4, which read the incoming
            // path from RawUrl. Request validation has been moved earlier in the pipeline by default and
            // routing no longer consumes this property, so we don't have to either.

            ValidationUtility.EnableDynamicValidation(HttpContext.Current);
            controllerContext.HttpContext.Request.ValidateInput();
        }
コード例 #6
0
        public virtual ModuleRequestResult ExecuteRequest(ModuleRequestContext context)
        {
            this.EnsureInitialized();
            this.RequestContext = this.RequestContext ?? new RequestContext(context.HttpContext, context.RouteData);
            var currentContext = HttpContext.Current;

            if (currentContext != null)
            {
                var isRequestValidationEnabled = ValidationUtility.IsValidationEnabled(currentContext);
                if (isRequestValidationEnabled == true)
                {
                    ValidationUtility.EnableDynamicValidation(currentContext);
                }
            }

            this.AddVersionHeader(this.RequestContext.HttpContext);
            this.RemoveOptionalRoutingParameters();

            var controllerName = this.RequestContext.RouteData.GetRequiredString("controller");

            // Construct the controller using the ControllerFactory
            var controller = this.ControllerFactory.CreateController(this.RequestContext, controllerName);

            try
            {
                // Check if the controller supports IDnnController
                var moduleController = controller as IDnnController;

                // If we couldn't adapt it, we fail.  We can't support IController implementations directly :(
                // Because we need to retrieve the ActionResult without executing it, IController won't cut it
                if (moduleController == null)
                {
                    throw new InvalidOperationException("Could Not Construct Controller");
                }

                moduleController.ValidateRequest = false;

                moduleController.DnnPage = context.DnnPage;

                moduleController.ModuleContext = context.ModuleContext;

                moduleController.LocalResourceFile = string.Format(
                    "~/DesktopModules/MVC/{0}/{1}/{2}.resx",
                    context.ModuleContext.Configuration.DesktopModule.FolderName,
                    Localization.LocalResourceDirectory,
                    controllerName);

                moduleController.ViewEngineCollectionEx = this.ViewEngines;

                // Execute the controller and capture the result
                // if our ActionFilter is executed after the ActionResult has triggered an Exception the filter
                // MUST explicitly flip the ExceptionHandled bit otherwise the view will not render
                moduleController.Execute(this.RequestContext);
                var result = moduleController.ResultOfLastExecute;

                // Return the final result
                return(new ModuleRequestResult
                {
                    ActionResult = result,
                    ControllerContext = moduleController.ControllerContext,
                    ModuleActions = moduleController.ModuleActions,
                    ModuleContext = context.ModuleContext,
                    ModuleApplication = this,
                });
            }
            finally
            {
                this.ControllerFactory.ReleaseController(controller);
            }
        }