Questions tagged [routedata]

38 questions
54
votes
1 answer

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

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?
Gene Reddick
  • 4,655
  • 4
  • 34
  • 35
20
votes
2 answers

What is Routedata.Values[""]?

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}", …
Lost
  • 12,007
  • 32
  • 121
  • 193
5
votes
4 answers

How can I get route attributes dotnet core 3?

I have upgraded dotnet core 2.2 to 3.preview 7. So after that, I can't get custom attributes. context.Resource in version 2.2 was type of AuthorizationFilterContext, but in version 3 is type of Microsoft.AspNetCore.Http.Endpoint. Now I couldn't…
Bahman Shafiei
  • 395
  • 5
  • 22
5
votes
1 answer

Web API: how to read action attribute and parameters from HttpContext

In regular class, I need to read following from the HttpContext: Controller and action name Action's attribute (I could get that through HttpActionContext.ActionDescriptor.GetCustomAttributes() but here I don't have HttpActionContext - I…
4
votes
1 answer

Error getting value from 'CompiledAssembly' when running site in IIS, fine within Visual Studio

I'm running a MVC project and utilizing Json, I have code that is running properly when running within Visual Studio, then I have a Site on IIS pointing to the same folder, when executed a URL from the IIS site my code doesn't perform the same as…
Derek
  • 653
  • 7
  • 20
4
votes
2 answers

ASP.NET MVC - RouteData set in filter action not bound to action method parameter

I have an action filter which (among other things), adds stuff to the RouteData. The value, however, is not picked up by the parameter in my action method. Any ideas why? Action Filter: public class SomeFilter : FilterAttribute, IActionFilter { …
Hossein
  • 1,090
  • 1
  • 8
  • 24
2
votes
1 answer

Retaining RouteData in Html.BeginForm()

I have been using a variant of the Html.BeginForm() method to attach an html attribute to my form, like this : @using (Html.BeginForm("actionname", "controllername", FormMethod.Post, new { id = "myform" })) Unfortunately this causes the form…
Arnab Chakraborty
  • 7,442
  • 9
  • 46
  • 69
2
votes
1 answer

How Do I Get RouteData Values from a Web Service in .Net 4.0

I am trying to extract an id number from a URL using a web service so that it can be used as a parameter for a where clause in a select statement that produces data from a database based on the id number of a record. That data will then be passed…
2
votes
2 answers

get parameters from URL in controller constructor

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…
Stefanvds
  • 5,868
  • 5
  • 48
  • 72
2
votes
1 answer

How to get url id value in controller?

I want to get the id of my current url and use it in a controller. http://localhost:14160/?id=69 this Request.RequestContext.RouteData.Values["id"] is returning null value. Any ideas? controller: public class HomeController : Controller { …
user2803474
  • 21
  • 2
  • 9
2
votes
1 answer

ASP.NET MVC Passing Lists to RouteData QueryString

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…
reach4thelasers
  • 26,181
  • 22
  • 92
  • 123
2
votes
1 answer

MvcSiteMapProvider not resolving depending on RouteData

I am attempting to use the MvcSiteMapProvider with an MVC 4 site, and am having a problem in a section of the site which has (for example) a Project Listing page and child Project Detail page. When you access the Detail page, the ID of the entity…
Matthew Sharpe
  • 3,667
  • 2
  • 25
  • 24
2
votes
1 answer

Getting RouteData in a Controller's constructor/attributes to route [Authorize]'s ConnectionString

Background I have a multitenant application that uses multiple databases per-tenant. I'm using CodeFirstMembership, so I have full controll over the SimpleMembership implementation. Both my User/Role entities are in the same DbContext as the rest…
Ryan Hayes
  • 5,290
  • 4
  • 42
  • 52
1
vote
1 answer

ASP.NET MVC3 ModelState and RouteData placement

in MVC3, is route data always in the modelState collection, or is it only in the modelState collection if that key is specifically requested as per the model binder for the applicable controller action ? To illustrate: public HomeController {…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
1
vote
0 answers

Can I use RouteData API for any agent?

network with nodes Let's say an agent is located at Node1 and the three resource units from one resource pool are located at Node2, 3, and 4 respectively. When an agent is to seize one resource unit on nodes and moves to it, I used customize…
SHLH
  • 13
  • 3
1
2 3