【发布时间】:2019-12-09 07:16:02
【问题描述】:
我基本上想这样做:
routes.MapRoute(
"Pass-through",
"/api/{*url}",
new { controller = "PassThrough", action = "PassThroughToApi" });
我将请求发送到的控制器有:
public ContentResult PassThroughToApi(string url = null)
但是,我希望能够同时限制 URL。如:
routes.MapRoute(
"Pass-through",
"/api/v1/some/specific/address/{whatever}/{parameters}",
new { controller = "PassThrough", action = "PassThroughToApi" });
但我仍然希望控制器将请求的 URL 作为变量获取,并且我不关心获取实际参数,只要 URL 与模式匹配即可。还是我应该从其他地方(例如上下文)获取请求的 URL,而不是作为参数传递给它?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing