Httpmodule resend/ recreate request

I have created an httpmodule that gets user ip information and append credentials to the header based on their IP. It does this every request though. I would like to listen for a 401 status response and then run the ip look up and resend the request through.

I have all the pieces in place, i can catch the 401 error, and attach credentials to a header, except i cannot figure out how to resend the request through with the new header.

Possibly transfer or rewrite?


I won't go into details why you've chosen such strategy as this doesn't sound very elegant. Anyway given your requirements I would set two cookies in the response, with authentication expiry date and hash value to validate expiry date. Then change the response to 301 redirect to the same url. Next time the request arrives I has set cookie which you identify/validate and attach the credential headers. Cookies example would be:

Set-Cookie: AuthExpiry=20/02/2012T12:30:12
Set-Cookie: AuthHash=38D67A30F9453E6A9A025A2395AC07EA198383A5

Where AuthHash is generated by concatenating GetSHA(AuthExpiry+yourSecretPhrase)

链接地址: http://www.djcxy.com/p/43796.html

上一篇: 限制HttpModule只处理某些请求

下一篇: Httpmodule重新发送/重新创建请求