我需要重定向到当前模块下的路径:
modulePath = "/test";
Get["/there"] = ...
Get["/here"] = routeParams => { return ????????????("/there"); }
Run Code Online (Sandbox Code Playgroud)
我希望"/ test/here"重定向到"/ test/there"
Chr*_*dal 11
您可以使用命名路由和Nancy.Linker.请参阅https://github.com/horsdal/Nancy.Linker
这是Nancy.Linker从NuGet 安装,依赖IResourceLinker并将代码更改为:
public class YourModule
{
public YourModule(IResourceLinker linker)
{
Get["theRoute", "/there"] = ...
Get["/here"] = Response.AsRedirect(linker.BuildAbsoluteUri(this.Context, "theRoute");
}
{
Run Code Online (Sandbox Code Playgroud)