Here is a picture I captured from < Professional IIS >
I am wondering why the web request and the resulting web content as the response have to go through the same ISAPI filters or applications in a circle fashion. I know that ISAPI applications and Filters are nothing but Win32 DLLs. This circle fashion is kind of like a function call/return manner, i.e., when the web request comes, the exported functions of ISAPI Filters are invoked, and then the Filters invoke the WWW Service, and the WWW Service invoke the exported functions of ISAPI Applicaitons, and they return all the way back reversly. So is this the root cause? (I hope you understand what I mean.)
Many thanks.
Typically, in IIS, WWW service would server web content - it would map the resource to appropriate ISAPI Extension (or handler) - mapping is typically done on the basis of request resource extension. Its extension's responsibility to throw actual content (say html) that will be then returned back to browser via www service. ISAPI filters sits in between - they can modify the request before ISAPI extension/application can process it. Similarly, they can modify the response (content) generated by the application before it is returned to the browser.
I believe that following would be better resources to understand IIS Architecture
http://learn.iis.net/page.aspx/101/introduction-to-iis-7-architecture/
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/843df643-1dbb-4fb6-910d-ec1965fa9e43.mspx?mfr=true
Related
I have been making my blog and wanted to know how come some blogs have web-address like 'www.xyz./articles/15748', while my blog have addresses such as 'www.xyz/articles/test.aspx'. I mean whether they are using some form of xml to populate their predefined webpage. If not so why is their web-page is not having any extension such as '.php' or '.htm' or '.aspx'.
It can be done with Url Rewriting.
For example how to use it in Asp.Net - http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
Basically it's a module that rewrites incoming url to that one that WebServer can process, and then rewrites output urls to the same as input urls
It depends on the framework they are using, if they are re-writing their URL's with a module in their web server, or handling HTTP requests with a custom HTTP handler (ASP.Net).
When calling a url that is suffixed with aspx, that means you are requesting a physical page that exists on a server, which is then trotted through the ASP.Net runtime using the WebForms framework and delivered to your browser.
Now, if you use the MVC framework instead of the WebForms framework, then your URLs don't refer to a page, but to objects and functions. If I were to request /User/Edit/1, that URL could map to the Edit function on User object, and we would pass in 1 as an argument.
In addition, some web servers have URL Rewriting functionality that allows you to map one URL to another, so it could listen for URL's without a suffix, and transparently route the request to a physical page.
Finally, in ASP.Net at least, you can write handlers in your application that will listen for HTTP requests, and if it so chooses it could also perform some transparent routing.
These are just a few ways, there are certainly others.
I have gone through the links mentioned below,
iis forum and HttpModules & Server.Transfer / Server.TransferRequest / RewritePath problems. but unable to catch the concept behind these transfer methods.
How are they works? And which one is preferred in different situation?
Can someone explain me TransferRequest vs Transfer methods for server side transfer in asp.net and its roles?
Thanks in advance
HttpServerUtility.Transfer Terminates execution of the current page and starts execution of provided URL.
This basically maps and executes a new ASP.NET Page (or serves a static file) corresponding to the url provided. It does this in-place in the current request pipeline, without applying new configuration to the new url, or re-running IIS modules for the new url. Because of this, its very fast, but it also prevents a lot of scenarios that are possible with TRQ.
HttpServerUtility.TransferRequest Performs an asynchronous execution of the provided URL.
This is a full IIS child request under the covers, which allows it to re-run the entire request pipeline for the new request as if it was a separate request, getting the correct configuration for it, and running all of the normal IIS modules including authentication, authorization, etc. For example, IIS will apply the authorization rules for the new url, as opposed to the previous url.
TransferRequest re-runs the entire request pipeline as if it were a separate request. This means that IIS and ASP.NET modules are re-applied; authentication and authorization rules for the new URL will be honored. Note that TransferRequest requires the integrated pipeline mode of IIS 7+, and the transfer can be to an ASP page or another resource like an XML file.
Transfer transfers execution from one ASP page to another ASP page on the server. Unlike TransferRequest, IIS and ASP.NET will NOT verify that the current user is authorized to view the resource delivered by the Transfer method. If you need to force reauthorization, and integrated pipeline mode is not an option, call Redirect instead of the Transfer method. Redirect triggers a client-side redirect so that the new request will be subjected to all authentication and authorization logic of IIS and ASP.NET.
We have a number of existing clients that point to urls like:
http://sub1.site.com/images/image1.jpg
/images is a virutal directory that points to a directory that actually contains image1.jpg on that server.
We're moving all of the files out of this directory and onto a separate server that will not run this same application.
The file will now only be available at:
http://sub2.site.com/image1.jpg
What is the best way to make it so clients requesting
http://sub1.site.com/images/image1.jpg will get the content that now resides at http://sub2.site.com/image1.jpg?
A few requirements:
We need the actual content to be returned through that url - not a 302 response.
We cannot modify the IIS server configuration - only the web.config for the site
Again, we're running asp.net 3.5
Thanks.
Not totally sure this would work, but you could setup URL Routing on the old site so all requests are sent to a handler and within that handler you could do a web request to get the file from it's new location.
I use a variation of the process to map image URLs to different locations and my handler does some database queries to get the mapped relationship and provide the correct image. I don't see why you could do a web request to get the image.
Since you are using IIS7, you can use the built in URL rewrite module.
You would want an inbound and an outbound rule to change \images\image1.jpg to \image1.jpg
It can get pretty involved, but this should be rather simple.
Assuming you can add handlers to your site (as in add a DLL to your /bin directory in the site) and with the restriction that you can't send 302 responses for better performance, then alternatively you could write a custom handler to grab all requests that match that URL pattern, do the web request for the sub2.site image from the original site via web client code, then serve it back out of the original site, sub1.site.com.
See How To Create an ASP.NET HTTP Handler by Using Visual C# .NET for the very basics of creating and setting up a custom handler. Then use the HttpWebRequest to make the request of sub2.site.com, as in the guide A Deeper Look at Performing HTTP Requests in an ASP.NET Page. Plus a little other code to handle errors, timeouts, passing the image through with as little processing and memory usage as possible, etc.
Depending on the response time/lag between the two servers, this may be slow, but it would fit all your requirements. But if the point of moving the images to site 2 was for performance (CPU or memory) or bandwidth limitations, then this solution would nullify any gains — and would actually make things worse. But if they were moved for other business or technical reasons though, then this solution might be helpful still.
If you have other control over the server or anything upstream from the server, you could use mod_proxy (or similar Windows/IIS tool) to intercept those URLs and forward them to another server and respond back with the real request. Depending on your network configuration and available servers, this could be the simplest, best performing solution.
Can IIS be configure to forward request to another web server? on serverfault has a quick process and link for an IIS 7.5 solution.
Is it at all possible to inject a request into IIS for a page, have IIS and ASP.Net handle it as normal, but get the response as html handed back to me programmatically?
Yes, I know that I could connect to port 80 using WebRequest and WebResponse, but that becomes difficult if you are accessing the IIS server from the same physical machine (loopback security controls et al).
Basically, I want to inject the request (eg for http://example.org/MyPage.aspx) between the points at which IIS would normally talk to the browser, and the point at which it would route it to the correct ASP.Net application, and get a response back from IIS between the points at which ASP.Net/IIS applies the httpfilters and hands the html back to the browser.
I'm predominantly working with IIS7 so if there is a solution that works just for IIS7 then thats not an issue.
You could implement a custom HttpModule, which would give you access to the IIS pipeline, including the final response. However, you would still need to initiate a request to IIS to actually kick off processing. Not sure if this would work for you.
From the MSDN documentation:
An HTTP module is an assembly that is
called on every request that is made
to your application. HTTP modules are
called as part of the request pipeline
and have access to life-cycle events
throughout the request. HTTP modules
therefore let you examine incoming
requests and take action based on the
request. They also let you examine the
outgoing response and modify it.
Gave you looked into the WebCkiebt class? You can make the request and get the response HTML.
http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadstring(v=VS.100).aspx
HI,
If I want to have log of all requests made within a web site including any http bad requests, is this possible?
For e.g I want to be able to see if every http request from the site including any for images that don't exist etc.
All the things an IIS log has.
Is this possible with HTTP Module or something like the ASP.net Health monitoring?
You would need to change the IIS configuration to let asp net engine to process all files, including static ones, this is not very practical. If you do this you could create and HTTPModule to intercept ANY request.
Why do you need to do this?