What am I trying to achieve: when someone navigates to the root of the web host I want to redirect them to /{pathbase}/metadata. Pre ServiceStack 6 I was able to achieve this with the below code:
app.Run(context =>
{
context.Response.Redirect("/{pathbase}/metadata");
return Task.CompletedTask;
});
The above now silently fails so I’ve attempted to do the same using minimal apis:
var app = builder.Build();
app.MapGet("/", context =>
{
context.Response.Redirect("/{pathbase}/metadata");
return Task.CompletedTask;
});
When I comment out https://github.com/DeonHeyns/RedirectRepro/blob/main/RoutesNotCalled/Configure.AppHost.cs#L5
[assembly: HostingStartup(typeof(RoutesNotCalled.AppHost))]
Then the endpoint is hit.
Two questions:
- Is the above approach correct?
- If not is there a recommended approach?
Repro: https://github.com/DeonHeyns/RedirectRepro
Thanks,
Deon