Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#mvc3 Actionlink未在URL中发送参数_C#_Asp.net Mvc 3 - Fatal编程技术网

C#mvc3 Actionlink未在URL中发送参数

C#mvc3 Actionlink未在URL中发送参数,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,我对MVC3和Actionlink有一些问题。我正在使用从我的模型传递的数据动态地构建一个HTML ActionLink 他认为: @for (int i = 0; i < Model.CountriesList.Count; i++) { <li class="sub">@Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", new {

我对MVC3和Actionlink有一些问题。我正在使用从我的模型传递的数据动态地构建一个
HTML ActionLink

他认为:

@for (int i = 0; i < Model.CountriesList.Count; i++)
{

<li class="sub">@Html.ActionLink(Model.CountriesList[i].countryname, 
                                 "PageSub", new { PageID = Model.PageNo, 
                                                  countryid = Model.CountriesList[i].countryid 
                                                 })</li>

}
当我直接输入时,我需要它在下面工作:

http://localhost/Pages/PageSub?PageID=136&countryid=196
这是我的控制器操作结果,它指向:

public ActionResult PageSub(int? PageID, int? countryid)
{

}
我已使用开发人员工具检查了代码,链接已按预期构建:

<li class="sub">
     <a href="/Pages/PageSub?PageID=136&countryid=196">
</li>
  • 有没有人有过类似的问题?如有任何建议,将不胜感激。谢谢

    试试这个:

    @Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", "Pages", new { PageID = Model.PageNo, countryid = Model.CountriesList[i].countryid }, null)
    

    你可能刚刚错过了,但它不应该是“i@Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", "Pages", new { PageID = Model.PageNo, countryid = Model.CountriesList[i].countryid }, null)