I'd like to redirect a request to another module if the application is being run for the first time (nancy).
// bootstrapper -> RequestStartup
pipelines.BeforeRequest.AddItemToEndOfPipeline(context =>
if(!_configuration.FirstRun)
return null;
return context.Request.Path != "/app/firstrun" ?
context.GetRedirect("/app/firstrun") : null;
});
The pipeline get's intercepted and the redirection happens - however I somehow loose all information about the request and thus, the AppModule never get's called. It also tries to locate a view called "DefaultStatusCodeHandlerResult" somehow (?) which obviously doesn't exist.
// app module
public class AppModule : NancyModule {
public AppModule(ServerConfiguration configuration) {
Get["firstrun"] = _ => {
if(!configuration.FirstRun)
return Response.AsRedirect("/home/");
return View["FirstRun"];
};
}
}
Am I doing something wrong? Or is there a better place to configure this behavior instead of the before request pipeline?
Aucun commentaire:
Enregistrer un commentaire