何时在管道中进行路由? [英] When does routing take place in the pipeline?

查看:90
本文介绍了何时在管道中进行路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时在ASP.NET MVC管道中进行路由?

IIS 7.0的ASP.NET应用程序生命周期概述

在第2步(执行网址映射)中吗?

我打算有一些具有ID的路线

激活/{id}"

忘记密码/{id}"

我希望能够在第4步-AuthenticateRequest中的管道中尽早访问ID.这样我就可以通过url的id部分将身份验证令牌传递给我的自定义身份验证模块.

那么我可以访问我的自定义身份验证模块中的id属性,还是必须从请求url中手动提取它?

感谢您的帮助,

邓肯

解决方案

似乎UrlRouting发生在第9步-PostResolveRequestCache.

实际上,它确实发生在AuthenticateRequest之后,它是第4步.

这是UrlRoutingModule的文档

我在反射器中查找了它的Init()方法,这就是它订阅PostResolveRequestCache事件的地方.

所以我想现在我必须尝试编写一些代码来优雅地手动从url中提取令牌.

When does routing take place in the ASP.NET MVC pipeline?

ASP.NET Application Life Cycle Overview for IIS 7.0

Is it in step number 2 (Perform Url Mapping)?

I intend to have a few routes that have an id

"activate/{id}"

"forgotpassword/{id}"

I would like to be able to access the id early on in the pipline in step 4 - AuthenticateRequest. So that I can pass an authentication token through the id part of the url to my custom authentication module.

So can I access the id property in my custom authentication module or do I have to manually extract it from the request url?

Thanks for your help,

Duncan

解决方案

It appears that the UrlRouting takes place at step number 9 - PostResolveRequestCache.

So it does in fact take place after AuthenticateRequest which is step number 4.

This is the document for UrlRoutingModule

I looked up it's Init() method in reflector and that is where it subscribes to the PostResolveRequestCache Event.

So I guess now I have to try and write some code that elegantly extracts the token from the url manually..

这篇关于何时在管道中进行路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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