0

我在 mvc 中做一个项目。

我尝试做的是获取路由的当前 ID,以便在上传处理程序方法中使用它,以将此值插入到我的数据库中:

是否可以在 mvc 的 ashx 文件中获取当前路由 ID?

我进行了很多搜索,并看到了一些答案,例如:ViewContext.RouteData.Values["id"];

我想做的是:

cmd.Parameters.Add("@Ident", SqlDbType.Int).Value = /*HERE write a line to get the current id*/;
4

1 回答 1

12

尝试:

Url.RequestContext.RouteData.Values["id"]
于 2013-09-02T14:44:47.980 回答