其实,没有必要,只要在view中这样获取就可以: <%=Html.ViewContext.RouteData.Values["id"]%> 就算没有id的参数也不会报错。 转载于:https://www.cnblogs.com/valu/p/5869451.html