这不应该需要新的视图或视图模型。正如您所描述的,您应该有两个操作,但代码可能如下所示:
控制器
public ActionResult GetEvents(string location){
var model = service.GetEventsByLocation(location);
return View("Events", model);
}
public ActionResult GetEventsById(int id){
var model = service.GetEventsById(id);
return View("Events", model);
}
服务
public MyViewModel GetEventsByLocation(string location){
//do stuff to populate a view model of type MyViewModel using a string
}
public MyViewModel GetEventsById(int id){
//do stuff to populate a view model of type MyViewModel using an id
}
基本上,如果您的视图将使用相同的视图模型并且唯一改变的是您如何获取该数据,那么您可以完全重用视图。