HttpResponse.AddOnSendingHeaders(Action<HttpContext>) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a callback that the ASP.NET runtime will invoke immediately before response headers are sent for this request.
public:
System::Web::ISubscriptionToken ^ AddOnSendingHeaders(Action<System::Web::HttpContext ^> ^ callback);
public System.Web.ISubscriptionToken AddOnSendingHeaders (Action<System.Web.HttpContext> callback);
member this.AddOnSendingHeaders : Action<System.Web.HttpContext> -> System.Web.ISubscriptionToken
Public Function AddOnSendingHeaders (callback As Action(Of HttpContext)) As ISubscriptionToken
Parameters
- callback
- Action<HttpContext>
The callback method.
Returns
An ISubscriptionToken object that represents the subscription to the OnSendingHeaders pseudo-event.
Remarks
Important
The AddOnSendingHeaders method is not invoked if the native module flushes the response first.
The pseudo-event OnSendingHeaders differs from the IHttpModule-level pipeline event in that it is a per-request subscription rather than a per-application subscription. The intent is that the callback may modify the response status code or may set a response cookie or header. Other usage notes and caveats:
This method is effective only when IIS runs in integrated pipeline mode pipeline and only if response headers haven't yet been sent for the current request.
The ASP.NET runtime does not guarantee anything about the thread that the callback is invoked on. For example, the callback may be invoked synchronously in a background thread if a background flush is being performed. Current is not guaranteed to be available in such a thread.
The callback must not call any method that manipulates the response entity body or that results in a flush. For example, the callback must not call Redirect, as that method may manipulate the response entity body.
The callback must contain only short-running synchronous code. Attempting to invoke an asynchronous operation or wait on such an operation could result in a deadlock.
The callback must not throw an exception; otherwise behavior is undefined.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기