解决Asp.net网站url重定向 form验证模块顺序问题 Solve Asp.net web site url redirection form validation module sequence

2007年04月26日• 追风逐月 • 分类: 技术开发 , 网站建设 April 26, 2007 Herd monthly • • Category: technology development, construction site

一直以来都在项目中使用了UrlRewritingNet模块来实现url重定向的功能,很是方便好用。 Has been used in the project UrlRewritingNet modules to achieve url redirection function is very easy-to-use. 但有一个问题一直没有解决,就是当用户访问需要登陆的页面是会自动转到login页面,这时其returl参数会将原始的url暴露出来,很是不爽。 However, there is one issue has not been resolved is that when users need to visit landing pages will be automatically transferred to the login page, then its returl parameters will be exposed in the original url, very不爽.
今天花了点时间研究了一下,发现 Today, the time spent on this, found

  1. UrlRewriteModule是在BeginRequest事件中进行重写的 UrlRewriteModule BeginRequest incident in the rewritten
  2. Form认证模块(FormsAuthenticationModule)是在AuthenticateRequest中进行权限判断的 Form Authentication Module (FormsAuthenticationModule) AuthenticateRequest conducted in the judge's authority
  3. AuthenticateRequest事件晚于BeginRequest执行,所以认证过程中产生的returl肯定是取不到原始的rawurl了 AuthenticateRequest BeginRequest event later than the implementation, certification process in the returl is certainly fail to get the original rawurl
  4. 为了让returl能够保持为原始的url,需要将UrlRewriteModule的重写改在AuthorizeRequest事件中执行 To allow for returl able to maintain the original url, the need to rewrite UrlRewriteModule incident to the implementation of the AuthorizeRequest

UrlRewritingNet没有提供这种选项,所幸的是这是个开源的工程,于是将其代码进行了一些修改。 UrlRewritingNet did not provide this option, is fortunate that this is open-source projects, so the code will be a number of amendments. 增加了一个RewriteOnRequestBegin的配置参数,在其初始化方法中修改代码如下: RewriteOnRequestBegin an additional configuration parameters, in its initialization method to modify the code as follows:

PLAIN TEXT PLAIN TEXT

C#: C #:

  1. if ( UrlRewriting. Configuration . RewriteOnRequestBegin ) If (UrlRewriting. Configuration. RewriteOnRequestBegin)

  2. { (

  3. context. BeginRequest = new EventHandler ( OnBeginRequest ) ; Context. BeginRequest = new EventHandler (OnBeginRequest);

  4. } )

  5. else Else

  6. { (

  7. context. AuthorizeRequest = new EventHandler ( OnBeginRequest ) ; Context. AuthorizeRequest = new EventHandler (OnBeginRequest);

  8. } )

这样我们就可以随便配置是要在认证前重新还是认证后重写了。 So that we can easily configure is to re-certification or certification before a rewrite.
参考: Reference:

  1. Certification flow chart form
  2. 事件执行顺序执行Application_BeginRequest Application_BeginRequest incident implementation of the implementation of the order
    执行Application_AuthenticateRequest Executive Application_AuthenticateRequest
    执行Application_AuthorizeRequest Executive Application_AuthorizeRequest
    执行Application_ResolveRequestCache Executive Application_ResolveRequestCache
    执行Application_AcquireRequestState Executive Application_AcquireRequestState
    执行Application_PreRequestHandlerExecute Executive Application_PreRequestHandlerExecute
    执行Application_PostRequestHandlerExecute Executive Application_PostRequestHandlerExecute
    执行Application_ReleaseRequestState Executive Application_ReleaseRequestState
    执行Application_UpdateRequestCache Executive Application_UpdateRequestCache
    执行Application_EndRequest Executive Application_EndRequest
标签: asp.net , google , UrlRewritingNet Tags: asp.net, google, UrlRewritingNet
本文链接: http://chyni.com/site-builder/aspnet-urlrewriting.html This paper links: http://chyni.com/site-builder/aspnet-urlrewriting.html

你可能还喜欢 You may also like



发表你的意见 Express your views

追风逐月 Zhuifeng monthly

提供网络赚钱、网赚经验、网赚工具、SEO、国外主机信息 The provision of the network to make money, Wangzhuan experience Wangzhuan tool, SEO, foreign host information
Herd monthly subscription blog feed
Subscribe to google Subscribe to Battery
Subscribe to the fresh fruit Subscribe to grasp shrimp
* 更多订阅本站方式请看订阅帮助 * See More Subscribe way to help subscribers