user2232273
user2232273

Reputation: 4974

How to get the current route id in mvc

im working on a project in mvc.

what i try to do is to get a the current id of the route to use it in a uploadhandler method to insert into this value into my database:

is it possible to get the current route id in a ashx file in mvc?

i have searching a lot and see some answer like: ViewContext.RouteData.Values["id"];

what im trying to do is like :

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

Upvotes: 0

Views: 10208

Answers (1)

Daniele
Daniele

Reputation: 1938

Try with:

Url.RequestContext.RouteData.Values["id"]

Upvotes: 12

Related Questions