isapi过滤器,如何实现url重定向?

creakmud 2003-08-30 07:55:11
如题,
...全文
127 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
celerityok 2004-03-18
  • 打赏
  • 举报
回复
mark!
masterz 2003-09-14
  • 打赏
  • 举报
回复
你搜索以下SF_NOTIFY_URL_MAP ,给的关键字已经很具体了,自己去搜索怎么设吧
creakmud 2003-09-05
  • 打赏
  • 举报
回复
to masterz()
怎么设置?

如果我想实现如下功能 当客户浏览http://test/a.doc时(a.doc不存在)由程序从数据库读取数据返回给客户,我该如何做?
masterz 2003-08-31
  • 打赏
  • 举报
回复
你的filter 设置了SF_NOTIFY_URL_MAP flag 么
creakmud 2003-08-31
  • 打赏
  • 举报
回复
to masterz()
试了,好象不行,根本没有执行到 OnUrlMap函数,是怎么回事呢?
zhi_liu6 2003-08-30
  • 打赏
  • 举报
回复
说穿了就是
Location: http://xxx/xxx
呵呵
masterz 2003-08-30
  • 打赏
  • 举报
回复
above is for ISAPI filter. the following is for ISAPI Extension

pCtxt->Reset();
CString strURL("http://www.csdn.net");
DWORD dwLen = strURL.GetLength();
pCtxt->ServerSupportFunction(HSE_REQ_SEND_URL_REDIRECT_RESP,
strURL.GetBuffer(0), &dwLen, NULL);
strURL.ReleaseBuffer();
masterz 2003-08-30
  • 打赏
  • 举报
回复
The following code demonstrates how to use an OnUrlMap notification in the filter to redirect a request to a different URL. If the URL contains a DoRedirect string (for example, http://server/doRedirect), the request will be redirected to http://www.microsoft.com.
DWORD CFiltRedirFilter::OnUrlMap(CHttpFilterContext* pCtxt,
PHTTP_FILTER_URL_MAP pMapInfo)
{
CHAR szRedirect [256];

if (strstr (pMapInfo->pszURL, "DoRedirect"))
{
CHAR szRedirect [256];
// replace www.microsoft.com with desired server
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "www.microsoft.com");
pCtxt->ServerSupportFunction ( SF_REQ_SEND_RESPONSE_HEADER,
(LPVOID) "302 Redirect",
(DWORD *) szRedirect,
0 );
// Print a message to the debug window
ISAPITRACE1 ("Redirecting to: %s\n", szRedirect);
// we are done with this request
return SF_STATUS_REQ_FINISHED_KEEP_CONN;
}
// URL did not contain a DoRedirect string.
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧