/// <inheritdoc/> protected override void InitializeRouteParameters(MvcProxyBase proxyControl) { var originalContext = this.Context.Request.RequestContext ?? proxyControl.Page.GetRequestContext(); this.SetControllerRouteParam(proxyControl); var controller = proxyControl.GetController(); if (!FrontendManager.AttributeRouting.HasAttributeRouting(controller.RouteData)) { var paramsMapper = this.GetDefaultParamsMapper(controller); if (paramsMapper != null) { var originalParams = MvcRequestContextBuilder.GetRouteParams(originalContext); var requestContext = proxyControl.RequestContext; var modelProperty = controller.GetType().GetProperty("Model"); if (modelProperty != null) { var model = modelProperty.GetValue(controller, null); var modelUrlKeyProperty = model == null ? null : model.GetType().GetProperty("UrlKeyPrefix"); var modelUrlKeyPrefix = modelUrlKeyProperty == null ? null : (string)modelUrlKeyProperty.GetValue(model, null); var expectedUrlKeyPrefix = string.IsNullOrEmpty(modelUrlKeyPrefix) ? null : "!" + modelUrlKeyPrefix; var currentUrlKeyPrefix = originalParams == null ? null : originalParams.FirstOrDefault(p => p.StartsWith("!", StringComparison.OrdinalIgnoreCase)); if (expectedUrlKeyPrefix == currentUrlKeyPrefix) { paramsMapper.ResolveUrlParams(originalParams, requestContext, modelUrlKeyPrefix); } else { this.GetPrefixParamsMapper(controller).ResolveUrlParams(originalParams, requestContext); RouteHelper.SetUrlParametersResolved(); } } else { paramsMapper.ResolveUrlParams(originalParams, requestContext); } if (!proxyControl.ContentTypeName.IsNullOrEmpty()) { controller.RouteData.Values.Add("contentTypeName", proxyControl.ContentTypeName); } } else { proxyControl.RequestContext.RouteData.Values.Remove(FeatherActionInvoker.ControllerNameKey); base.InitializeRouteParameters(proxyControl); } } else { if (this.ShouldProcessRequest(controller) && FrontendManager.AttributeRouting.UpdateRouteData(this.Context, controller.RouteData)) { //// Attribute routing was successful. RouteHelper.SetUrlParametersResolved(); } } }
protected override void ExecuteController(MvcProxyBase proxyControl) { // Stop processing, personalized widgets are executed asynchronously if (proxyControl is PersonalizedWidgetProxy) { return; } var controller = proxyControl.GetController(); if (proxyControl.IsIndexingMode() && controller.GetIndexRenderMode() == IndexRenderModes.NoOutput) { return; } try { this.TryLoadTempData(controller); base.ExecuteController(proxyControl); } catch (Exception ex) { this.HandleControllerException(ex); } finally { this.TrySaveTempData(controller); } }
/// <summary> /// Logs exceptions thrown by the invocation of <see cref="ControllerActionInvoker"/> /// </summary> /// <param name="proxyControl">The proxy control.</param> protected override void ExecuteController(MvcProxyBase proxyControl) { var controller = proxyControl.GetController(); if (proxyControl.IsIndexingMode() && controller.GetIndexRenderMode() == IndexRenderModes.NoOutput) return; try { this.TryLoadTempData(controller); base.ExecuteController(proxyControl); } catch (Exception ex) { if (!(ex is ThreadAbortException)) if (Exceptions.HandleException(ex, ExceptionPolicyName.IgnoreExceptions)) throw; this.Context.Response.Clear(); if (this.ShouldDisplayErrors()) this.Context.Response.Write(Res.Get<InfrastructureResources>().ErrorExecutingController); } finally { this.TrySaveTempData(controller); } }
private void SetControllerRouteParam(MvcProxyBase proxyControl) { var requestContext = proxyControl.RequestContext; string controllerName; var widgetProxy = proxyControl as MvcWidgetProxy; if (widgetProxy != null && !string.IsNullOrEmpty(widgetProxy.WidgetName)) { controllerName = widgetProxy.WidgetName; } else { controllerName = SitefinityViewEngine.GetControllerName(proxyControl.GetController()); } requestContext.RouteData.Values[FeatherActionInvoker.ControllerNameKey] = controllerName; }
protected override void ExecuteController(MvcProxyBase proxyControl) { var controller = proxyControl.GetController(); if (proxyControl.IsIndexingMode() && controller.GetIndexRenderMode() == IndexRenderModes.NoOutput) return; try { this.TryLoadTempData(controller); base.ExecuteController(proxyControl); } catch (Exception ex) { this.HandleControllerException(ex); } finally { this.TrySaveTempData(controller); } }
/// <inheritdoc/> protected override void InitializeRouteParameters(MvcProxyBase proxyControl) { var originalContext = this.Context.Request.RequestContext ?? proxyControl.Page.GetRequestContext(); this.SetControllerRouteParam(proxyControl); var controller = proxyControl.GetController(); if (!FrontendManager.AttributeRouting.HasAttributeRouting(controller.RouteData)) { var paramsMapper = this.GetDefaultParamsMapper(controller); if (paramsMapper != null) { var originalParams = MvcRequestContextBuilder.GetRouteParams(originalContext); var requestContext = proxyControl.RequestContext; paramsMapper.ResolveUrlParams(originalParams, requestContext); if (!proxyControl.ContentTypeName.IsNullOrEmpty()) { controller.RouteData.Values.Add("contentTypeName", proxyControl.ContentTypeName); } } else { proxyControl.RequestContext.RouteData.Values.Remove(DynamicUrlParamActionInvoker.ControllerNameKey); base.InitializeRouteParameters(proxyControl); } } else { if (FrontendManager.AttributeRouting.UpdateRouteData(this.Context, controller.RouteData)) { //// Attribute routing was successful. RouteHelper.SetUrlParametersResolved(); } } controller.TempData.Add("IsInPureMode", proxyControl.IsInPureMode); }
protected override void ExecuteController(MvcProxyBase proxyControl) { var controller = proxyControl.GetController(); if (proxyControl.IsIndexingMode() && controller.GetIndexRenderMode() == IndexRenderModes.NoOutput) { return; } try { this.TryLoadTempData(controller); base.ExecuteController(proxyControl); } catch (Exception ex) { this.HandleControllerException(ex); } finally { this.TrySaveTempData(controller); } }
/// <summary> /// Logs exceptions thrown by the invocation of <see cref="ControllerActionInvoker"/> /// </summary> /// <param name="proxyControl">The proxy control.</param> protected override void ExecuteController(MvcProxyBase proxyControl) { var controller = proxyControl.GetController(); if (proxyControl.IsIndexingMode() && controller.GetIndexRenderMode() == IndexRenderModes.NoOutput) { return; } try { this.TryLoadTempData(controller); base.ExecuteController(proxyControl); } catch (Exception ex) { if (!(ex is ThreadAbortException)) { if (Exceptions.HandleException(ex, ExceptionPolicyName.IgnoreExceptions)) { throw; } } this.Context.Response.Clear(); if (this.ShouldDisplayErrors()) { this.Context.Response.Write(Res.Get <InfrastructureResources>().ErrorExecutingController); } } finally { this.TrySaveTempData(controller); } }
/// <inheritdoc/> protected override void InitializeRouteParameters(MvcProxyBase proxyControl) { var originalContext = this.Context.Request.RequestContext ?? proxyControl.Page.GetRequestContext(); this.SetControllerRouteParam(proxyControl); var controller = proxyControl.GetController(); if (!FrontendManager.AttributeRouting.HasAttributeRouting(controller.RouteData)) { var paramsMapper = this.GetDefaultParamsMapper(controller); if (paramsMapper != null) { var originalParams = MvcRequestContextBuilder.GetRouteParams(originalContext); var requestContext = proxyControl.RequestContext; paramsMapper.ResolveUrlParams(originalParams, requestContext); if (!proxyControl.ContentTypeName.IsNullOrEmpty()) controller.RouteData.Values.Add("contentTypeName", proxyControl.ContentTypeName); } else { proxyControl.RequestContext.RouteData.Values.Remove(FeatherActionInvoker.ControllerNameKey); base.InitializeRouteParameters(proxyControl); } } else { if (FrontendManager.AttributeRouting.UpdateRouteData(this.Context, controller.RouteData)) { //// Attribute routing was successful. RouteHelper.SetUrlParametersResolved(); } } controller.TempData.Add("IsInPureMode", proxyControl.IsInPureMode); }