/// <summary> /// Creates a <see cref="CreatedAtRouteResult"/> object that produces a Created (201) response. /// </summary> /// <typeparam name="TRedirectController">Controller, from which the action is specified.</typeparam> /// <param name="routeName">The name of the route to use for generating the URL.</param> /// <param name="action"> /// The <see cref="Expression{TDelegate}"/>, from which action name, /// controller name and route values are resolved. /// </param> /// <param name="value">The content value to format in the entity body.</param> /// <returns>The created <see cref="CreatedAtRouteResult"/> for the response</returns> public static CreatedAtRouteResult CreatedAtRoute <TRedirectController>( this Controller controller, string routeName, Expression <Action <TRedirectController> > action, object value) { return(controller.CreatedAtRoute(routeName, action, routeValues: null, value: value)); }
/// <summary> /// Creates a <see cref="CreatedAtRouteResult"/> object that produces a Created (201) response. /// </summary> /// <typeparam name="TRedirectController">Controller, from which the action is specified.</typeparam> /// <param name="routeName">The name of the route to use for generating the URL.</param> /// <param name="action"> /// The <see cref="Expression{TDelegate}"/>, from which action name, /// controller name and route values are resolved. /// </param> /// <param name="routeValues">Additional route data to use for generating the URL.</param> /// <param name="value">The content value to format in the entity body.</param> /// <returns>The created <see cref="CreatedAtRouteResult"/> for the response</returns> public static CreatedAtRouteResult CreatedAtRoute <TRedirectController>( this Controller controller, string routeName, Expression <Action <TRedirectController> > action, object routeValues, object value) { var expressionRouteValues = ExpressionRouteHelper.Resolve(action, routeValues, addControllerAndActionToRouteValues: true); return(controller.CreatedAtRoute( routeName, expressionRouteValues.RouteValues, value)); }