我需要重定向到当前模块下的路径:

modulePath = "/test";
Get["/there"] = ...
Get["/here"] = routeParams => { return ????????????("/there"); }

我希望将“/test/here”重定向到“/test/there”

最佳答案

您可以使用命名路由和Nancy.Linker。参见https://github.com/horsdal/Nancy.Linker

那就是从NuGet安装Nancy.Linker,获取对IResourceLinker的依赖并将代码更改为:

public class YourModule
{
    public YourModule(IResourceLinker linker)
    {
        Get["theRoute", "/there"] = ...
        Get["/here"] = Response.AsRedirect(linker.BuildAbsoluteUri(this.Context, "theRoute");
    }
{

关于南希重定向到当前模块下的路由,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24631922/

10-16 22:22