不知道我在这里做什么,但任何和所有参数都通过我的控制器作为null
即使它们在呈现的HTML中明确定义。路由参数通过null
查看
@Html.ActionLink("Export to Spreadsheet", "Export", "ZipCodeTerritory"
, new {
@searchZip = Model.searchZip,
@searchActiveOnly = Model.searchActiveOnly,
@searchTerritory = Model.searchTerritory,
@searchState = Model.searchState
})
控制器
public ActionResult Export(string searchZip, bool? searchActiveOnly, string searchTerritory, string searchState)
{
渲染HTML
<a href="/ZipCodeTerritory/Export?Length=16" searchactiveonly="True" searchstate="CA" searchterritory="" searchzip="">Export to Spreadsheet</a>
在参数字典中的@是不是必需的,可能是什么是扔掉这个。您呈现的HTML对于URL来说相当糟糕,这意味着它是无法正常运行的ActionLink助手。看起来ActionLink正在将您的路线参数改为“”标签属性。尝试删除ActionLink – Tommy
的'new {}'部分中的@将其删除,但仍然没有运气。也注意到关于呈现的链接,但是删除'@'并没有改变任何东西。 – NealR