【发布时间】:2019-04-24 16:41:03
【问题描述】:
我想创建一个路由,在 url 中路由无限的字符串集合。
像这样:
https://github.com/{orgName}/{projectName}/blob/{branchName}/{folderName1}/{folderName2}/.../{folderNameN}/{fileName}
例如
https://github.com/AiursoftWeb/Nexus/blob/master/Account/Controllers/AccountController.cs
将被路由到此操作。路由结果应为:
orgName: AiursoftWeb
projectName: Nexus
branchName: master
folderNames: string[2] of:
"Account"
"Controllers"
fileName: AccountController.cs
我如何做到这一点?
我尝试了以下方法:
[Route("Folders/ViewContent/{siteName}/{folderNames}")]
public async Task<IActionResult> ViewContent(string siteName, params string[] folderNames)
{
throw new NotImplementedException();
}
但它不起作用。
【问题讨论】:
-
你只是想返回静态文件吗?因为只使用 StaticFilesMiddleware 会容易得多。
-
@Valuator 不。我正在创建一个 API。
标签: c# asp.net-mvc asp.net-core routes