routedata

get parameters from URL in controller constructor

自闭症网瘾萝莉.ら 提交于 2020-06-26 07:57:28
问题 I need to write some code to find an ID in my database of a Project. Users are coupled to a project and all the projects have a lot of connections to other objects, such as Sessions. Now I need to check before running any Actions, if the user trying to access the Session, is connected to the same project as the session is connected to. For this i want to use an [Attribute] on the Actions. MVC: creating a custom [AuthorizeAttribute] which takes parameters? This question and answer got me

Asp.Net MVC Beta: Previous RouteData overrides current RouteData?

独自空忆成欢 提交于 2019-12-08 05:43:45
问题 I have something similar to the following method: public ActionResult Details(int id) { var viewData = new DetailsViewData { Booth = BoothRepository.Find(id), Category = ItemType.HotBuy }; return View(viewData); } and the following Route: routes.MapRoute("shows","shows/{controller}/{action}/{id}", new {id = 0}); Everything worked fine before the Beta, when I had Preview 3. Now the method will fill the id correctly the first time I execute the action. However the second time the controller's

Asp.Net MVC Beta: Previous RouteData overrides current RouteData?

为君一笑 提交于 2019-12-06 14:52:23
I have something similar to the following method: public ActionResult Details(int id) { var viewData = new DetailsViewData { Booth = BoothRepository.Find(id), Category = ItemType.HotBuy }; return View(viewData); } and the following Route: routes.MapRoute("shows","shows/{controller}/{action}/{id}", new {id = 0}); Everything worked fine before the Beta, when I had Preview 3. Now the method will fill the id correctly the first time I execute the action. However the second time the controller's ModelState contains the last-use id value. This causes the ActionInvoker to use it in the method's

What is Routedata.Values[“”]?

好久不见. 提交于 2019-12-04 17:26:31
问题 I am surprised to see that there is no article which answers this question with any details. I have few questions related to RouteData.Values[""] . I saw this code: public ActionResult Index() { ViewBag.Message = string.Format("{0}---{1}--{2}", RouteData.Values["Controller"], RouteData.Values["action"], RouteData.Values["id"]); return View(); } Here it is basically reading values which potentially sounds like "Meta-data" of the controller. Or is it something that View can also pass to

ASP.NET MVC Passing Lists to RouteData QueryString

早过忘川 提交于 2019-12-03 14:12:56
问题 The recommended approach for passing lists of values as a QueryString is www.site.com/search?value=1&value=2&value=3&value=4 ASP.NET handles this well: string value = QueryString.Get("value"); // returns "1,2,3,4" But I can't figure out a way of passing these values by into RouteData. The obvious approach would be to add int[] value = {1,2,3,4}; into the RouteData and have super smart MVC sort things out for me. Unfortunately MVC is dump when it comes to passing arrays into RouteData, it

What is Routedata.Values[“”]?

假装没事ソ 提交于 2019-12-03 10:19:06
I am surprised to see that there is no article which answers this question with any details. I have few questions related to RouteData.Values[""] . I saw this code: public ActionResult Index() { ViewBag.Message = string.Format("{0}---{1}--{2}", RouteData.Values["Controller"], RouteData.Values["action"], RouteData.Values["id"]); return View(); } Here it is basically reading values which potentially sounds like "Meta-data" of the controller. Or is it something that View can also pass to Controller? RouteData.Values is used for accessing the values/querystring values inserted by the classes

ASP.NET MVC Passing Lists to RouteData QueryString

十年热恋 提交于 2019-12-03 05:09:45
The recommended approach for passing lists of values as a QueryString is www.site.com/search?value=1&value=2&value=3&value=4 ASP.NET handles this well: string value = QueryString.Get("value"); // returns "1,2,3,4" But I can't figure out a way of passing these values by into RouteData. The obvious approach would be to add int[] value = {1,2,3,4}; into the RouteData and have super smart MVC sort things out for me. Unfortunately MVC is dump when it comes to passing arrays into RouteData, it basically calls .ToString() adding value=int[] to my QueryString. I tried adding the values to

How do you access the current RouteData from View in .net MVC?

独自空忆成欢 提交于 2019-11-30 04:11:21
If I want to directly access the RouteData (the current action or parameter values for example) from the View , rather than having to pass it in from the controller as part of the ViewData , what class would i use? this.ViewContext.RouteData should do the trick. 来源: https://stackoverflow.com/questions/1134776/how-do-you-access-the-current-routedata-from-view-in-net-mvc

How do you access the current RouteData from View in .net MVC?

孤街浪徒 提交于 2019-11-29 02:03:32
问题 If I want to directly access the RouteData (the current action or parameter values for example) from the View , rather than having to pass it in from the controller as part of the ViewData , what class would i use? 回答1: this.ViewContext.RouteData should do the trick. 来源: https://stackoverflow.com/questions/1134776/how-do-you-access-the-current-routedata-from-view-in-net-mvc