0

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.

1
  • Are you saying you want your URL to look like http://localhost:7264/Asortiman/Browse/327? Commented May 11, 2011 at 12:20

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks i solved it on much easier way: string url = HttpContext.Current.Request.Url.AbsoluteUri;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.