简体   繁体   English

HTML.RenderAction不使用我的routeValue参数

[英]Html.RenderAction not using my routeValue parameters

I'm calling a RenderAction but my PartialViewResult is not receiving my sent parameter. 我正在调用RenderAction,但是我的PartialViewResult没有收到我发送的参数。

Here's my Default Route: 这是我的默认路线:

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

Here's my Call: 这是我的电话:

@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { level = Model.InvestmentGroup });}

Here's my Action: 这是我的动作:

 public PartialViewResult InvestmentGroupDropDown(Guid? selectedId)
        {
        }

I reach my Action no problem but the value I'm trying to send from my Model. 我没有达到Action的问题,但我想从Model传递的价值。 Is not there when I reach my Action. 当我执行动作时不在那里。 I can see the value in debug mode plain as day in the RenderActions parameter. 我可以在RenderActions参数中看到调试模式下的值。 Why does it seem to be ignoring my parameter? 为什么它似乎忽略了我的参数?

I should be getting a Guid in my PartialViewResult, instead i'm getting null. 我应该在PartialViewResult中得到一个Guid,而不是null。

Tieson T. provided me with an answer! Tieson T.为我提供了答案! Thank you! 谢谢!

I didn't realise the object name mattered here but it does. 我没有意识到这里的对象名称很重要,但确实如此。 I changed level to the parameter name of my Action 'selectedId' and voila we have cookies! 我将级别更改为我的操作“ selectedId”的参数名称,瞧,我们有了Cookie!

@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { **level** = Model.InvestmentGroup });}
@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { **selectedId** = Model.InvestmentGroup });}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM