在 MSVC4 中,在表单中生成链接的可接受方法是/Controller/Action/parameter
什么?
我在 .ascx 中有这个...
<%=Html.ActionLink(linkText:=doc.DocumentName, _
actionName:="CommissionPayment", _
controllerName:="GetDocument", _
routeValues:=New With {.DocID = doc.DocumentID}, _
htmlAttributes:=Nothing)
%>
...返回这个:
http://localhost:56869/GetDocument/CommissionPayment?DocID=5511972
我在 RouteConfig.vb 中有这个
routes.MapRoute(
"CommissionPayment", _
"GetDocument/CommissionPayment/{DocID}", _
New With {.controller = "GetDocument", .action = "GetOBDocument"}, _
New With {.DocID = "\d+"} _
)
...并且此 URL 正确调用 GetDocument 控制器上的 GetOBDocument 方法:
http://localhost:56869/GetDocument/CommissionPayment/123123123
但是,ActionLink 调用返回的带有“?DocID=123”的 URL 不会调用任何内容。是无效垃圾;“没有找到您要查的资源”。我想那是因为它与 CommissionPayment 路由的 /\d+ 模式不匹配,所以服务器去寻找一个不存在的 CommissionPayment 操作。
显然,我可以省略 maproute 的东西并使用?DocID
,或者我可以手动编写 URL。可能是后者,因为用户下载文件并且这种形式欺骗了浏览器,让我控制它下载到的文件名。
但我想了解这里发生了什么。