6.39HttpContextForwardBuilder 构建器
创建于 2026 年 8 月 17 日约 1 分钟读完
HttpContextForwardBuilder 构建器是框架提供专门用来转换 HttpContext 请求上下文所需的各项设置。HttpContextForwardBuilder 的构造函数是私有的,因此无法直接使用 new 关键字进行实例化,不过,框架提供了 HttpContext.CreateForwardBuilder 的多个扩展重载方法创建 HttpContextForwardBuilder 的实例。
httpContext.CreateForwardBuilder(httpMethod, requestUri, forwardOptions); // forwardOptions 参数的类型为 HttpContextForwardOptionshttpContext.CreateForwardBuilder(requestUri, forwardOptions); // 自动获取 HttpContext.Request.Method 方法进行设置框架内部尚未提供手动构建 HttpContextForwardBuilder 并使用 Send/SendAsync 方法进行转发的功能,请改用 ForwardAsync 相关方法。