开发者

IIS 404 dynamic redirect

开发者 https://www.devze.com 2023-01-23 08:23 出处:网络
Question for you guys. If I am capturing a 404 error through an isapi filter in IIS and calling a handler with code to redirect the user by taking in their url request as a parameter and running a que

Question for you guys. If I am capturing a 404 error through an isapi filter in IIS and calling a handler with code to redirect the user by taking in their url request as a parameter and running a query on the database. Can I run into issues making that dynamic server side redirect if multiple users are being caught by the error handler simultaneously. I believe the first execution is being terminated, the second one completes, and both users are开发者_StackOverflow redirected to the same url.

Any thoughts? Thanks


I am capturing a 404 error through an isapi filter in IIS...

I am not clear if you are writing the filter, or if the filter already exists. I'll assume you are writing it yourself since this is stackoverflow, and I'll assume C or C++ since you said ISAPI.

In that case....An ISAPI filter will get an HTTP_FILTER_CONTEXT for each request incoming request. You need to structure your code so as to keep those things separate; pass the pointer to that structure around to each function in your code, if using C, or store it in object state if using C++. Also your code needs to be thread-safe.

Can I run into issues making that dynamic server side redirect if multiple users are being caught by the error handler simultaneously.

Yes, if you don't follow the requirements for writing a multi-threaded filter.


There are simpler ways to accomplish what you want, I think. IIS allows administrators to specify URLs to deliver a "custom HTTP Error Response". The URL can be anything on the webserver, including a dynamic web script, like a page written in ASPNET or PHP or whatever. You may want to use a 302 redirect to your dynamic page; that's a common pattern. There's no need to resort to writing an ISAPI filter.

0

精彩评论

暂无评论...
验证码 换一张
取 消