Guest User

Untitled

a guest
Feb 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // örnek: /category/8
  2. [Route("~/category/{id:int}")]
  3. public ActionResult Index(int id)
  4. {
  5. ViewBag.Title = id;
  6. return View();
  7. }
  8. // örnek /category/NoName
  9. [Route("~/category/{name}")]
  10. public ActionResult Index(string name)
  11. {
  12. ViewBag.Title = name;
  13. return View();
  14. }
  15. // örnek:/category/5 çalışır
  16. // örnek:/category/10000000000 çalışmaz çünkü int.MaxValue'den büyük
  17. // örnek:/category/0 çalışmaz çünkü tanımlanan min(1) değerinden küçük
  18.  
  19. [Route("~/category/{id:int:min(1)}")]
  20. public ActionResult Index(int id)
  21. {
  22. ViewBag.Title = id;
  23. return View();
  24. }
  25. // örnek: /category/test çalışır.
  26. // örnek: /category/bilgisayar çalışmaz.
  27. // örnek: /category/ çalışır.
  28. [Route("~/category/{name:maxlength(5)?}")]
  29. public ActionResult Index(string name)
  30. {
  31. ViewBag.Title = name;
  32. return View();
  33. }
Add Comment
Please, Sign In to add comment