获得启动URL信息 [英] Get URL information in Startup

查看:117
本文介绍了获得启动URL信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个asp.net MVC 5项目中,我使用的是武士刀owin基于middlewere来处理身份验证。在 Start.cs中文件我有启动类的<​​code>配置方法。
有没有办法让配置方法中请求的完整网址?我需要得到的它的最后部分将被存储在cookie

 公共无效配置(IAppBuilder应用程序){
     app.UseCookieAuthentication(新CookieAuthenticationOptions {...}
     //这里的东西来获取完整URL     //其他认证code在这里
}


解决方案

启动时运行的请求周期之外。事实上,它只能运行一次,它曾经再次运行此之前多个连续的网址,可以进行维修(当程序池回收,服务器重新启动等等)

长与短,即使你的可能的访问URL,它不会对你有任何好的,因为它只会成为被访问的第一个随机URL,这可能会或可能不适用到任何你想在这里做的。

In an asp.net MVC 5 project I'm using a katana owin based middlewere to handle the authentication. Inside the Start.cs file I have the Startup class with the Configuration method. Is there a way to get the full URL of the request inside the Configuration method? I need to get the last part of it to be stored in a cookie

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

     // other authentication code here
}

解决方案

Startup runs outside of the request-cycle. In fact, it only runs once, and then multiple successive URLs can be serviced before it ever runs again (when AppPool recycles, server restarts, etc.)

Long and short, even if you could access the URL, it wouldn't do you any good because it would simply be the first random URL that was accessed, which may or may not be applicable to whatever you're trying to do here.

这篇关于获得启动URL信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆