"Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } RedirectToRouteResult 可跳转至任何一条匹配的路由规则。是以利用路由转移可以跳转到其他控制器的 Action。 五、ContentResult ...
DefaultApplicationModelProvider:初始化ControllerModel, 添加 Controller 相关的各种信息,添加用户自定义 Filter,遍历 ControllerTypes :创建 ControllerModel-->初始化Properties-->初始化Parameters。 CorsApplicationModelProvider:跨域资源相关逻辑,添加CorsAuthorizationFilterFactory,DisableCorsAuthorizationFilter,CorsAuthorizationF...
ActionExecutedContext postActionContext = InvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters);//走到这一步,Action 方法已成功执行,针对一些特殊的认证过滤器,即使Action执行成功,仍然需要进行一些处理的//例如针对不同的用户执行不同反馈操作AuthenticationChallengeConte...
我们利用MethodInfo的声明类型得到Controller的类型,将剔除“Controller”后缀的类型名称作为ControllerName属性(表示Controller的名称),作为Action名称的ActionName属性则直接返回方法名称。Parameters属性返回一个ParameterDeor数组,而根据ParameterInfo对象构建的ParameterDeor是对参数的描述。 publicclassActionDeor { publicMethodInfo ...
"{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ).RouteHandler = new AsyncMvcRouteHandler(); } 1. 2. 3. 4. 5. 6. 7. 8. 9. #p# ...
现在我们来看看具体的代码.参数模型绑定执行肯定在具体的Action方法执行之前,在ControllerActionInvoker的InvokeAction方中,执行Action方法是InvokeActionMethodWithFilters,在其前一行代码是IDictionary<string, object> parameters = GetParameterValues(controllerContext, actionDescriptor); 这个方法的目的把Action的所有参数值根据...
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults...
Attributes Gets the attributes associated with the action. Controller Gets or sets the ControllerModel. DisplayName Gets the action display name. Filters Gets the IFilterMetadata instances associated with the action. Parameters Gets the parameters associated with this action. Properties Gets a set of...
Parameters actionName String The name of the action. controllerName String The name of the pageModel. routeValues Object The route data to use for generating the URL. fragment String The fragment to add to the URL. Returns RedirectToActionResult The created Re...
Without known conditions to safeguard against, returning a specific type could suffice. The preceding action accepts no parameters, so parameter constraints validation isn't needed. When multiple return types are possible, it's common to mix anActionResultreturn type with the primitive or complex retu...