public static IActionResult LoadingPage(this Microsoft.AspNetCore.Mvc.Controller controller, string viewName, string redirectUri) { controller.HttpContext.Response.StatusCode = 200; controller.HttpContext.Response.Headers["Location"] = ""; return(controller.View(viewName, new RedirectViewModel { RedirectUrl = redirectUri })); }
public static ViewResult GetView(this Microsoft.AspNetCore.Mvc.Controller ctrl, [CallerMemberName] string name = "", object model = null) { name = GetLastMethodName(name); if (InvocationHub.IsModuleInDebugMode()) { return(ctrl.View(name, model)); } else { var mdlName = ctrl.ControllerContext.HttpContext.Items[Consts.CONTEXT_ITEM_KEY_THEME_MODULE_NAME].ToString(); var controllerName = ctrl.GetType().Name.Replace("Controller", "", StringComparison.OrdinalIgnoreCase); var path = $"{Consts.MODULES_BASE_PATH}\\{mdlName}\\Views\\{controllerName}\\"; var file = ""; try { file = Directory.GetFiles(path, $"{name}.*").Single(); } catch (FileNotFoundException) { throw new ViewFileNotFoundException(mdlName, controllerName, name); } return(ctrl.View($"~/{path.Replace("\\","/")}{new FileInfo(file).Name}", model)); } }
public static IActionResult RAFailureView(this Controller controller, string viewName, object model) { controller.Response.SetFailureState(); return(controller.View(viewName, model)); }
/// <summary> /// 错误视图 /// </summary> /// <typeparam name="TError">ViewErrorDto</typeparam> /// <param name="controller">控制器</param> /// <param name="error">错误信息</param> /// <param name="viewName">错误视图名称</param> /// <returns></returns> public static ViewResult ErrorView <TError>(this Controller controller, TError error, string viewName = "Error") where TError : ViewErrorDto { return(controller.View(viewName, error)); }
public static IActionResult ValidateAndView(this Controller controller, object model = null, bool mapModel = false) { controller.UpdateValidations(model, mapModel); return(controller.View(model)); }