C# 如何在mvc中将@Url.Action中的值传递给控件?

C# 如何在mvc中将@Url.Action中的值传递给控件?,c#,asp.net-mvc,asp.net-mvc-4,jquery-mobile,C#,Asp.net Mvc,Asp.net Mvc 4,Jquery Mobile,我试图将@Url.Action中的值传递给控制器,但它作为Contoller/Action/id,并返回“找不到视图”。下面是我的代码 查看 <a href="@Url.Action("Index", "DirectPutawayDetails", new { id = @home[j].test.ToString()})" class="ui-li-has-count" data-role="button" data-ajax="false" data-mini="true" styl

我试图将@Url.Action中的值传递给控制器,但它作为Contoller/Action/id,并返回“找不到视图”。下面是我的代码

查看

<a href="@Url.Action("Index", "DirectPutawayDetails", new { id = @home[j].test.ToString()})" class="ui-li-has-count" data-role="button"  data-ajax="false" data-mini="true" style="background-color:#52616D;color:white">
                @home[j].test.ToString() <span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="background-color: white; color: #52616D">@home[j].think.ToString() </span></a>
我无法将id值分配给home.test model属性。它显示

对象引用未设置为对象的实例


directseach.home对象包含哪些内容?您能为视图和控制器添加附加代码吗?@ShaiAharoni当用户单击href标记并将其分配给我的模型属性测试时,我需要获取值。您确定@home[j]不为空吗?@ya。准确地说是它的视图模型。实际上使用视图模型,我在一个视图模型中放置了3个类。但是无法将值分配给类。什么是
@home[j]
?您是否正在循环中构造
@Url.Action(…
    public ActionResult Index(string id)
    {  
        directsearch.home.test = id;

        return view()    
    }