Petras
Petras

Reputation: 4759

How do I get the route and query string values in a mvc view

If I have this URL:

http://stackoverflow.com/question/ask?type=great

How do I get the complete route and query string values in the View most economically eg this

/question/ask?type=great

Upvotes: 0

Views: 360

Answers (2)

Ryand.Johnson
Ryand.Johnson

Reputation: 1906

If you want to get to it from the View, you could use httpcontext

like this:

@HttpContext.Current.Request.Path

Upvotes: 1

Ryand.Johnson
Ryand.Johnson

Reputation: 1906

you can set the action method in your controller to automatically parse the query string for you. You don't need to do anything to your route.

get query string values in mvc

Upvotes: 0

Related Questions