Create route for root path, '/', with ServiceStack

前端 未结 3 1711
后悔当初
后悔当初 2020-12-31 11:10

I\'m trying to set a RestPath for root, \'/\', but its not allowing me to. Its saying RestPath \'/\' on Type \'MainTasks\' is not Valid

Is there a way t

3条回答
  •  心在旅途
    2020-12-31 11:59

    This worked for me. I just added the RawHttpHandler and rewrote the request path. Worked like a champ. (This is found in my AppHost's Configure function.)

    var conf = new EndpointHostConfig();
    {
        DefaultRedirectPath = "/foo",
        AllowFileExtensions = { { "eot" }, { "svg" }, { "ttf" }, { "woff" } },
    };
    
    conf.RawHttpHandlers.Add(r =>
    {
        if (r.RawUrl == "/")
        {
            HttpContext.Current.RewritePath(conf.DefaultRedirectPath);
        }
    
        return null;
    });
    
    this.SetConfig(conf);
    

提交回复
热议问题