如何在 Internet 信息服务 (IIS) 中将 .sample 文件扩展名映射到 ASP.NET。
注意 在将配置文件更改为包含对新处理程序的引用后,ASP.NET Development Server 将处理对新资源的请求。若要启用 IIS 以处理该请求,请参见下面的过程。
当用户请求一个其 URL 以 .sample 结尾的资源时,Web 服务器将该请求转发给 ASP.NET。然后 ASP.NET 调用 HTTP 处理程序,后者返回一个响应。该响应由该处理程序动态创建;不需要存在具有文件扩展名 .sample 的文件。有关 ASP.NET 如何与 Web 服务器交互的更多信息,请参见 ASP.NET 生命周期。
Visual Basic Imports System.Web Public Class HelloWorldHandler Implements IHttpHandler Public Sub ProcessRequest(ByVal context As _ System.Web.HttpContext) Implements _ System.Web.IHttpHandler.ProcessRequest Dim request As HttpRequest = context.Request Dim response As HttpResponse = context.Response ' This handler is called whenever a file ending ' in .sample is requested. A file with that extension ' does not need to exist.