You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用自定义类向Html.ActionLink传递参数时Parametros属性未生效的问题求助

使用自定义类向Html.ActionLink传递参数时Parametros属性未生效的问题求助

我现在遇到一个棘手的问题:想通过自定义的Pantalla类给Html.ActionLink传递参数,但最后一个Parametros属性始终不生效,其他属性都能正常映射到ActionLink里,我猜测是不是object类型在这里的用法有问题,想请大家帮忙排查下。

我的ActionLink调用代码如下:

@Html.ActionLink(pantalla.Descripcion, pantalla.Action, pantalla.Controlador, pantalla.Parametros)

自定义的Pantalla类结构是这样的:

public class Pantalla
{
    public int IdPantalla { get; set; }
    public string Descripcion { get; set; }
    public string Controlador { get; set; }
    public string Action { get; set; }
    public object Parametros { get; set; }
}

我实例化这个类的时候是这么写的:

new Pantalla() { 
    IdPantalla=11, 
    Descripcion = "Consultas Abiertas Seguridad Social",  
    Controlador = "ReportViewer", 
    Action="EditViewerV2",  
    Parametros=new{pReport="27f31533-e9f4-485f-acc3-6f420ea28014" } 
}

目前的情况是,除了Parametros之外,其他属性都能正确对应到ActionLink的参数中,唯独这个参数传不过去。有没有大佬能指点下问题出在哪里?非常感谢!

备注:内容来源于stack exchange,提问作者Félix

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 07:08:11