How to manipulate a header and then continue with it in C#?
DWORD OnPreProc(HTTP_FILTER_CONTEXT *pfc, HTTP_FILTER_PREPROC_HEADERS *pHeaders)
{
if (ManipulateHeaderInSomeWay(pfc, pHeaders))
{
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
return SF_STATUS_REQ_FINISHED;
}
I now want to rewrite this ISAPI filter as a managed module for the IIS7. So I have something like this:
private void OnMapRequestHandler(HttpContext context)
{
ManipulateHeaderInSomeWay(context);
}
And now what? The request seems not to do what it should?
I already wrote an IIS7 native module that implements the same method. But this method has a return value with which I can tell what to do next:REQUEST_N开发者_StackOverflow社区OTIFICATION_STATUS CMyModule::OnMapRequestHandler(IN IHttpContext *pHttpContext, OUT IMapHandlerProvider *pProvider)
{
if (DoSomething(pHttpContext))
{
return RQ_NOTIFICATION_CONTINUE;
}
return RQ_NOTIFICATION_FINISH_REQUEST;
}
So is there a way to send my manipulated context again?
I finally found it. As I stated in the comments I add two headers to the request that are needed by my DLL that finally handles the request. The url
header contains the path to the DLL. So I have to do a redirect to that DLL.
This is done with the following code:
private void OnMapRequestHandler(HttpContext context)
{
ManipulateHeaderInSomeWay(context);
string url = context.Request.Header["url"]; // path of the DLL
// now this is the important call!
context.Server.TransferRequest(url, true);
}
精彩评论