Vocabulary question

I am using ASP.NET MVC2 and I would like to create a URL based on the current in the address bar inside the HtmlHelper extension. So far I have this:

url = helper.ViewContext.RequestContext.RouteData.Values .Aggregate<KeyValuePair<String, Object>>((w, next) => w + next); 

But this does not compile. Does anyone have a good idea on how to solve this Aggregate feature?

0
linq asp.net-mvc aggregate
source share
1 answer

Use this:

 helper.ViewContext.RequestContext.RouteData.Values .Select(x => x.Value.ToString()) .Aggregate((c, next) => c + next); 

But since you want something like a URL, I suggest you use this:

 helper.ViewContext.RequestContext.RouteData.Values .Select(x => x.Value.ToString()) .Aggregate((c, next) => c + "/" + next); 

Grz, Kris.

+2
source share

All Articles