Goran Bralo
Goran Bralo

Reputation: 463

asp.net mvc url to string

i am creating mvc application and is it possible to get the url to string somehow? my url is like:http://localhost:7264/Asortiman/Browse?kategorije=327 and in the head of some view i would like to get this url like string and take last 3 digits in this case 327 and use it as param in my function.

Upvotes: 0

Views: 205

Answers (1)

Mert Susur
Mert Susur

Reputation: 583

Why dont you do it at the Controller level and send it with the ViewBag dynamic object?

I Suppose your Controller is Asortiman and your Action method is Browse. Then if you define your method like;

public ActionResult Browse(int kategorije){
ViewBag.KategoriJe = kategorije;
return View();
}

Then at the view you can now reach it with the same dynamic object. For further use see the default mvc application project at the vs2010

Upvotes: 1

Related Questions