本文介绍了MVCContrib ActionFilter PassParametersDuringRedirect仍在查询字符串中传递引用类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在asp.net mvc 2 rc应用程序中使用PRG模式.

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

我发现MVCContrib项目具有一个自定义操作过滤器,该过滤器将自动将参数持久存储在TempData中

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

谁能解释我如何使用MVCContrib的PassParametersDuringRedirect过滤器属性不传递查询字符串中的ViewModel类型.

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

我看到发布了补丁来解决此问题,但在最新的支持MVC 2 RC的MvcContrib被注释如下

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);
        }

非常感谢您的帮助.

谢谢

推荐答案

与杰里米·斯金纳(Jeremy Skinner)聊天后修复.

Fixed after a chat with Jeremy Skinner.

http://github.com/mvccontrib/MvcContrib/commit/135411386b6817def9aaa493493ff582788ba377

http://github.com/mvccontrib/MvcContrib/commit/135411386b6817def9aaa493493ff582788ba377

这篇关于MVCContrib ActionFilter PassParametersDuringRedirect仍在查询字符串中传递引用类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!