This is how I generate a URL in ASP.NET MVC currently:

Url.Action("Index", new { page = 2 })

In previous frameworks I have used, there were special url functions which created a url based on the current url, only modifying the parts you wanted to change. This is in Pylons:

{{ url.current(page=2) }}

This would come in handy with partial views, where the partial view may be showing a list of items but not necessarily know which controller they belong to.

Two questions - why is such an obviously useful feature missing from ASP.NET MVC, and is there some common alternative way of doing what I mentioned with partial views? Maybe I'm approaching partial views completely wrong?

有帮助吗?

解决方案

why is such an obviously useful feature missing from ASP.NET MVC

What makes you think that such feature is missing:

string url = Url.Action(null, new { page = 2 });

or:

string url = Url.RouteUrl(new { page = 2 });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top