在 Startup 中获取 URL 信息

Get URL information in Startup

在一个 asp.net MVC 5 项目中,我使用基于 katana owin 的 middlewere 来处理身份验证。在 Start.cs 文件中,我有 Startup class 和 Configuration 方法。 有没有办法在 Configuration 方法中获取完整的 URL 请求?我需要将它的最后一部分存储在 cookie

public void Configuration(IAppBuilder app) {
     app.UseCookieAuthentication(new CookieAuthenticationOptions { ... }
     // something here to get the full URL

     // other authentication code here
}

启动在请求周期之外运行。事实上,它只运行一次,然后可以在它再次运行之前为多个连续的 URL 提供服务(当 AppPool 回收、服务器重新启动等时)

总而言之,即使您可以访问URL,它对您也没有任何好处,因为它只是第一个随机[=16] =] 已访问,这可能适用于也可能不适用于您在此处尝试执行的任何操作。