internal static void ActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, TextWriter textWriter) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (string.IsNullOrEmpty(actionName)) { throw new ArgumentException(SR.GetString("Common_NullOrEmpty"), "actionName"); } RouteValueDictionary routeValueDictionary = routeValues; routeValues = MergeDictionaries(new RouteValueDictionary[] { routeValues, htmlHelper.ViewContext.RouteData.Values }); routeValues["action"] = actionName; if (!string.IsNullOrEmpty(controllerName)) { routeValues["controller"] = controllerName; } bool flag = false; VirtualPathData virtualPathForArea = htmlHelper.RouteCollection .GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null, routeValues); if (virtualPathForArea == null) { throw new InvalidOperationException(SR.GetString("Common_NoRouteMatched")); } if (flag) { routeValues.Remove("area"); if (routeValueDictionary != null) { routeValueDictionary.Remove("area"); } } if (routeValueDictionary != null) { routeValues[Guid.NewGuid().ToString()] = new DictionaryValueProvider <object>(routeValueDictionary, CultureInfo.InvariantCulture); } RouteData routeData = CreateRouteData(virtualPathForArea.Route, routeValues, virtualPathForArea.DataTokens, htmlHelper.ViewContext); HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext; var parentModuleRequestContext = (ModuleRequestContext)htmlHelper.ViewContext.RequestContext; RequestContext context = new ModuleRequestContext(httpContext, routeData, parentModuleRequestContext.ModuleContext) { PageControllerContext = parentModuleRequestContext.PageControllerContext }; ChildActionMvcHandler httpHandler = new ChildActionMvcHandler(context); httpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(httpHandler), textWriter, true); }
// Helpers private static IHttpHandler PrepareActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, out HttpContextBase httpContext) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (String.IsNullOrEmpty(actionName)) { throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName"); } RouteValueDictionary additionalRouteValues = routeValues; routeValues = MergeDictionaries(routeValues, htmlHelper.ViewContext.RouteData.Values); routeValues["action"] = actionName; if (!String.IsNullOrEmpty(controllerName)) { routeValues["controller"] = controllerName; } bool usingAreas; VirtualPathData vpd = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null /* name */, routeValues, out usingAreas); if (vpd == null) { throw new InvalidOperationException(MvcResources.Common_NoRouteMatched); } if (usingAreas) { routeValues.Remove("area"); if (additionalRouteValues != null) { additionalRouteValues.Remove("area"); } } if (additionalRouteValues != null) { routeValues[ChildActionValueProvider.ChildActionValuesKey] = new DictionaryValueProvider <object>(additionalRouteValues, CultureInfo.InvariantCulture); } RouteData routeData = CreateRouteData(vpd.Route, routeValues, vpd.DataTokens, htmlHelper.ViewContext); httpContext = htmlHelper.ViewContext.HttpContext; RequestContext requestContext = new RequestContext(httpContext, routeData); IHttpHandler handler = new ChildActionMvcHandler(requestContext); return(handler); }
internal static void ActionHelper(HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, TextWriter textWriter) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (string.IsNullOrEmpty(routeName)) { throw new ArgumentNullException("routeName"); } routeValues = MergeDictionaries(routeValues, htmlHelper.ViewContext.RouteData.Values); var virtualPathForArea = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, routeName, routeValues); var routeData = CreateRouteData(virtualPathForArea.Route, routeValues, virtualPathForArea.DataTokens, htmlHelper.ViewContext); var httpContext = htmlHelper.ViewContext.HttpContext; var actionMvcHandler = new ChildActionMvcHandler(new RequestContext(httpContext, routeData)); httpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute((IHttpHandler)actionMvcHandler), textWriter, true); }
internal static void ActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, TextWriter textWriter) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (string.IsNullOrEmpty(actionName)) { throw new ArgumentException("Common_NullOrEmpty", "actionName"); } var dictionary = routeValues; routeValues = MergeDictionaries(new[] { routeValues, htmlHelper.ViewContext.RouteData.Values }); routeValues["action"] = actionName; if (!string.IsNullOrEmpty(controllerName)) { routeValues["controller"] = controllerName; } //bool flag; var data = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null, routeValues); // out flag); if (data == null) { throw new InvalidOperationException("Common_NoRouteMatched"); } //if (flag) //{ // routeValues.Remove("area"); // if (dictionary != null) // dictionary.Remove("area"); //} //if (dictionary != null) // routeValues[ChildActionValueProvider.ChildActionValuesKey] = new DictionaryValueProvider<object>(dictionary, CultureInfo.InvariantCulture); var routeData = CreateRouteData(data.Route, routeValues, data.DataTokens, htmlHelper.ViewContext); var httpContext = htmlHelper.ViewContext.HttpContext; var context = new RequestContext(httpContext, routeData); var httpHandler = new ChildActionMvcHandler(context); httpContext.Server.Execute((IHttpHandler)_wrapForServerExecuteMethod.Invoke(null, new object[] { httpHandler }), textWriter, true); }
// Helpers internal static void ActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, TextWriter textWriter) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (String.IsNullOrEmpty(actionName)) { throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName"); } routeValues = MergeDictionaries(routeValues, htmlHelper.ViewContext.RouteData.Values); routeValues["action"] = actionName; if (!String.IsNullOrEmpty(controllerName)) { routeValues["controller"] = controllerName; } bool usingAreas; VirtualPathData vpd = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null /* name */, routeValues, out usingAreas); if (vpd == null) { throw new InvalidOperationException(MvcResources.Common_NoRouteMatched); } if (usingAreas) { routeValues.Remove("area"); } RouteData routeData = CreateRouteData(vpd.Route, routeValues, vpd.DataTokens, htmlHelper.ViewContext); HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext; RequestContext requestContext = new RequestContext(httpContext, routeData); ChildActionMvcHandler handler = new ChildActionMvcHandler(requestContext); httpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(handler), textWriter, true /* preserveForm */); }
// Helpers internal static void ActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, TextWriter textWriter) { if (htmlHelper == null) { throw new ArgumentNullException("htmlHelper"); } if (String.IsNullOrEmpty(actionName)) { throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName"); } RouteValueDictionary additionalRouteValues = routeValues; routeValues = MergeDictionaries(routeValues, htmlHelper.ViewContext.RouteData.Values); routeValues["action"] = actionName; if (!String.IsNullOrEmpty(controllerName)) { routeValues["controller"] = controllerName; } bool usingAreas; VirtualPathData vpd = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null /* name */, routeValues, out usingAreas); if (vpd == null) { throw new InvalidOperationException(MvcResources.Common_NoRouteMatched); } if (usingAreas) { routeValues.Remove("area"); if (additionalRouteValues != null) { additionalRouteValues.Remove("area"); } } if (additionalRouteValues != null) { routeValues[ChildActionValueProvider.ChildActionValuesKey] = new DictionaryValueProvider<object>(additionalRouteValues, CultureInfo.InvariantCulture); } RouteData routeData = CreateRouteData(vpd.Route, routeValues, vpd.DataTokens, htmlHelper.ViewContext); HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext; RequestContext requestContext = new RequestContext(httpContext, routeData); ChildActionMvcHandler handler = new ChildActionMvcHandler(requestContext); httpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(handler), textWriter, true /* preserveForm */); }