MVCContrib ActionFilter PassParametersDuringRedire

2019-07-13 17:39发布

I am attempting to use the PRG pattern in an asp.net mvc 2 rc application.

I found that the MVCContrib project has a custom action filter that will auto persist the parameters in TempData

In an action I have the following

return this.RedirectToAction(c => c.Requested(accountAnalysis));

however this is adding a querystring param to the request e.g

http://mysite.com/account/add?model=MyProject.Models.AccountAnalysisViewModel

Can anyone explain how I can use the PassParametersDuringRedirect filter attribute from MVCContrib to not pass the ViewModel type in the querystring.

I see a patch was issued to fix this however in the latest MvcContrib that supports MVC 2 RC it is commented out as follows

public static RedirectToRouteResult RedirectToAction<T>(this Controller controller, Expression<Action<T>> action)
            where T : Controller
        {
            /*var body = action.Body as MethodCallExpression;
            AddParameterValuesFromExpressionToTempData(controller, body);
            var routeValues = Microsoft.Web.Mvc.Internal.ExpressionHelper.GetRouteValuesFromExpression(action);
            RemoveReferenceTypesFromRouteValues(routeValues);
            return new RedirectToRouteResult(routeValues);*/
            return new RedirectToRouteResult<T>(action);
        }

Any help much appreciated.

Thanks

1条回答
登录 后发表回答