Get URL information in Startup

馋奶兔 提交于 2019-12-12 03:07:36

问题


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
}

回答1:


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.



来源:https://stackoverflow.com/questions/38080036/get-url-information-in-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!