本文整理汇总了C#中IHttpHandler.ProcessRequest方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpHandler.ProcessRequest方法的具体用法?C# IHttpHandler.ProcessRequest怎么用?C# IHttpHandler.ProcessRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpHandler
的用法示例。
在下文中一共展示了IHttpHandler.ProcessRequest方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyAndProcessRequest
// synchronous code
protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) {
if (httpHandler == null) {
throw new ArgumentNullException("httpHandler");
}
httpHandler.ProcessRequest(HttpContext.Current);
}
示例2: VerifyAndProcessRequest
protected override void VerifyAndProcessRequest(IHttpHandler handler, HttpContextBase context)
{
Precondition.Require(handler, () => Error.ArgumentNull("handler"));
Precondition.Require(context, () => Error.ArgumentNull("context"));
handler.ProcessRequest(context.Unwrap());
}
示例3: VerifyAndProcessRequest
protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext)
{
if (httpHandler == null) {
throw new ArgumentNullException("httpHandler");
}
var origHttpHandler = httpContext.Handler;
try {
httpContext.Handler = httpHandler;
httpHandler.ProcessRequest(HttpContext.Current);
} finally {
httpContext.Handler = origHttpHandler;
}
}
示例4: CaptureOutput
public static string CaptureOutput(this HttpContext ctx, IHttpHandler page)
{
var old = ctx.Response.Output;
try
{
var writer = new StringWriter();
ctx.Response.Output = writer;
page.ProcessRequest(ctx);
return writer.ToString();
}
finally
{
ctx.Response.Output = old;
}
}
示例5: ProcessRequest
public static void ProcessRequest(this IHttpChannel channel, IHttpHandler handler, HttpServerSettings settings)
{
var context = new HttpContextImpl(channel, settings);
var res = context.Response;
using (res.OutputStream)
{
try
{
var app = handler as ExpressApplication;
if (app != null)
{
if (!app.Process(context))
{
res.StatusCode = (int)HttpStatusCode.NotFound;
res.StatusDescription = "Not found";
res.ContentType = "text/plain";
res.Write("Resource not found!");
}
res.Flush();
res.End();
}
else
{
var workerRequest = new HttpWorkerRequestImpl(context, settings);
handler.ProcessRequest(new HttpContext(workerRequest));
workerRequest.EndOfRequest();
}
}
catch (Exception e)
{
Console.Error.WriteLine(e);
res.StatusCode = (int)HttpStatusCode.InternalServerError;
res.ContentType = "text/plain";
res.Write(e.ToString());
}
}
}
示例6: ExecuteInternal
private void ExecuteInternal(IHttpHandler handler, TextWriter writer, bool preserveForm, bool setPreviousPage, VirtualPath path, VirtualPath filePath, string physPath, Exception error, string queryStringOverride)
{
if (handler == null)
{
throw new ArgumentNullException("handler");
}
HttpRequest request = this._context.Request;
HttpResponse response = this._context.Response;
HttpApplication applicationInstance = this._context.ApplicationInstance;
HttpValueCollection form = null;
VirtualPath path2 = null;
string queryStringText = null;
TextWriter writer2 = null;
AspNetSynchronizationContext syncContext = null;
this.VerifyTransactionFlow(handler);
this._context.PushTraceContext();
this._context.SetCurrentHandler(handler);
bool enabled = this._context.SyncContext.Enabled;
this._context.SyncContext.Disable();
try
{
try
{
this._context.ServerExecuteDepth++;
path2 = request.SwitchCurrentExecutionFilePath(filePath);
if (!preserveForm)
{
form = request.SwitchForm(new HttpValueCollection());
if (queryStringOverride == null)
{
queryStringOverride = string.Empty;
}
}
if (queryStringOverride != null)
{
queryStringText = request.QueryStringText;
request.QueryStringText = queryStringOverride;
}
if (writer != null)
{
writer2 = response.SwitchWriter(writer);
}
Page page = handler as Page;
if (page != null)
{
if (setPreviousPage)
{
page.SetPreviousPage(this._context.PreviousHandler as Page);
}
Page page2 = this._context.Handler as Page;
if ((page2 != null) && page2.SmartNavigation)
{
page.SmartNavigation = true;
}
if (page is IHttpAsyncHandler)
{
syncContext = this._context.InstallNewAspNetSynchronizationContext();
}
}
if (((handler is StaticFileHandler) || (handler is DefaultHttpHandler)) && !DefaultHttpHandler.IsClassicAspRequest(filePath.VirtualPathString))
{
try
{
response.WriteFile(physPath);
}
catch
{
error = new HttpException(0x194, string.Empty);
}
}
else if (!(handler is Page))
{
error = new HttpException(0x194, string.Empty);
}
else
{
if (handler is IHttpAsyncHandler)
{
bool isInCancellablePeriod = this._context.IsInCancellablePeriod;
if (isInCancellablePeriod)
{
this._context.EndCancellablePeriod();
}
try
{
IHttpAsyncHandler handler2 = (IHttpAsyncHandler) handler;
IAsyncResult result = handler2.BeginProcessRequest(this._context, null, null);
if (!result.IsCompleted)
{
bool flag3 = false;
try
{
try
{
}
finally
{
Monitor.Exit(applicationInstance);
flag3 = true;
}
//.........这里部分代码省略.........
示例7: ProcessPage
private void ProcessPage(IController controller, IHttpHandler page, HttpContext httpContext)
{
PreSendView(controller, page);
page.ProcessRequest(httpContext);
PostSendView(controller, page);
}
示例8: Execute
internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude)
{
// If the target handler is not Page, the transfer must not occur.
// InTransit == true means we're being called from Transfer
bool is_static = (handler is StaticFileHandler);
if (isTransfer && !(handler is Page) && !is_static)
throw new HttpException ("Transfer is only allowed to .aspx and static files");
HttpRequest request = context.Request;
string oldQuery = request.QueryStringRaw;
if (queryString != null) {
request.QueryStringRaw = queryString;
} else if (!preserveForm) {
request.QueryStringRaw = String.Empty;
}
HttpResponse response = context.Response;
WebROCollection oldForm = request.Form as WebROCollection;
if (!preserveForm) {
request.SetForm (new WebROCollection ());
}
TextWriter output = writer;
if (output == null)
output = response.Output;
TextWriter previous = response.SetTextWriter (output);
string oldExePath = request.CurrentExecutionFilePath;
bool oldIsInclude = context.IsProcessingInclude;
try {
context.PushHandler (handler);
if (is_static) // Not sure if this should apply to Page too
request.SetFilePath (exePath);
request.SetCurrentExePath (exePath);
context.IsProcessingInclude = isInclude;
if (!(handler is IHttpAsyncHandler)) {
handler.ProcessRequest (context);
} else {
IHttpAsyncHandler asyncHandler = (IHttpAsyncHandler) handler;
IAsyncResult ar = asyncHandler.BeginProcessRequest (context, null, null);
WaitHandle asyncWaitHandle = ar != null ? ar.AsyncWaitHandle : null;
if (asyncWaitHandle != null)
asyncWaitHandle.WaitOne ();
asyncHandler.EndProcessRequest (ar);
}
} finally {
if (oldQuery != request.QueryStringRaw) {
if (oldQuery != null && oldQuery.Length > 0) {
oldQuery = oldQuery.Substring (1); // Ignore initial '?'
request.QueryStringRaw = oldQuery; // which is added here.
} else
request.QueryStringRaw = String.Empty;
}
response.SetTextWriter (previous);
if (!preserveForm)
request.SetForm (oldForm);
context.PopHandler ();
request.SetCurrentExePath (oldExePath);
context.IsProcessingInclude = oldIsInclude;
}
}
示例9: ExecuteInternal
//.........这里部分代码省略.........
if ((handler is StaticFileHandler || handler is DefaultHttpHandler) &&
!DefaultHttpHandler.IsClassicAspRequest(filePath.VirtualPathString)) {
// cannot apply static files handler directly
// -- it would dump the source of the current page
// instead just dump the file content into response
try {
response.WriteFile(physPath);
}
catch {
// hide the real error as it could be misleading
// in case of mismapped requests like /foo.asmx/bar
error = new HttpException(404, String.Empty);
}
}
else if (!(handler is Page)) {
// disallow anything but pages
error = new HttpException(404, String.Empty);
}
else if (handler is IHttpAsyncHandler) {
// Asynchronous handler
// suspend cancellable period (don't abort this thread while
// we wait for another to finish)
bool isCancellable = _context.IsInCancellablePeriod;
if (isCancellable)
_context.EndCancellablePeriod();
try {
IHttpAsyncHandler asyncHandler = (IHttpAsyncHandler)handler;
if (!AppSettings.UseTaskFriendlySynchronizationContext) {
// Legacy code path: behavior ASP.NET <= 4.0
IAsyncResult ar = asyncHandler.BeginProcessRequest(_context, null, null);
// wait for completion
if (!ar.IsCompleted) {
// suspend app lock while waiting
bool needToRelock = false;
try {
try { }
finally {
_context.SyncContext.DisassociateFromCurrentThread();
needToRelock = true;
}
WaitHandle h = ar.AsyncWaitHandle;
if (h != null) {
h.WaitOne();
}
else {
while (!ar.IsCompleted)
Thread.Sleep(1);
}
}
finally {
if (needToRelock) {
_context.SyncContext.AssociateWithCurrentThread();
}
}
}
// end the async operation (get error if any)
示例10: ProcessRequest
private static HttpResponse ProcessRequest(IHttpHandler page, TextWriter writer)
{
var response = new HttpResponse(writer);
var context = new HttpContext(HttpContext.Current.Request, response);
context.SetSessionStateBehavior(SessionStateBehavior.Required);
page.ProcessRequest(context);
return response;
}
示例11: ShowDebugInfo
private void ShowDebugInfo(HttpContext context, IHttpHandler handler)
{
if( s_IntegratedPipeline == false ) {
handler.ProcessRequest(context);
}
else {
bool isAfterMapRequestHandler = false;
try {
context.RemapHandler(handler);
}
catch( InvalidOperationException ) {
// 在IIS7的集成管线模式下,当前阶段 >= MapRequestHandler 时,会引发这个异常
isAfterMapRequestHandler = true;
}
if( isAfterMapRequestHandler )
handler.ProcessRequest(context);
}
}
示例12: MoveNext
//.........这里部分代码省略.........
yield_13:
if (_this.PostAcquireRequestState != null){
//foreach (bool stop in RunHooks (PostAcquireRequestState))
// yield return stop;
if (currentEnumerator == null) {
currentYield = 13;
currentEnumerator = _this.RunHooks(_this.PostAcquireRequestState).GetEnumerator();
}
while (currentEnumerator.MoveNext())
return true;
ResetEnumerator();
}
#endif
//
// From this point on, we need to ensure that we call
// ReleaseRequestState, so the code below jumps to
// `release:' to guarantee it rather than yielding.
//
if (_this.PreRequestHandlerExecute != null)
foreach (bool stop in _this.RunHooks (_this.PreRequestHandlerExecute))
if (stop)
goto release;
try {
_this.context.BeginTimeoutPossible ();
if (handler != null){
IHttpAsyncHandler async_handler = handler as IHttpAsyncHandler;
if (async_handler != null){
_this.must_yield = true;
_this.in_begin = true;
async_handler.BeginProcessRequest (_this.context, new AsyncCallback(_this.async_handler_complete_cb), handler);
} else {
_this.must_yield = false;
handler.ProcessRequest (_this.context);
}
}
} catch (ThreadAbortException taex){
object obj = taex.ExceptionState;
Thread.ResetAbort ();
_this.stop_processing = true;
if (obj is StepTimeout)
_this.ProcessError (new HttpException ("The request timed out."));
} catch (Exception e){
_this.ProcessError (e);
} finally {
_this.in_begin = false;
_this.context.EndTimeoutPossible ();
}
if (_this.must_yield) {
//yield return stop_processing;
current = _this.stop_processing;
currentYield = 14;
return true;
}
else if (_this.stop_processing)
goto release;
yield_14:
// These are executed after the application has returned
if (_this.PostRequestHandlerExecute != null)
foreach (bool stop in _this.RunHooks (_this.PostRequestHandlerExecute))
if (stop)
goto release;