开发者

asp.net mvc url to string

开发者 https://www.devze.com 2023-03-04 21:47 出处:网络
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

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 stri开发者_JAVA技巧ng and take last 3 digits in this case 327 and use it as param in my function.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消