本文整理汇总了C#中HttpContextBase.RewritePath方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextBase.RewritePath方法的具体用法?C# HttpContextBase.RewritePath怎么用?C# HttpContextBase.RewritePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpContextBase
的用法示例。
在下文中一共展示了HttpContextBase.RewritePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostMapRequestHandler
/// <summary>
/// Performs the cleanup after the
/// request had been routed
/// </summary>
/// <param name="context">The current HTTP request context</param>
public virtual void PostMapRequestHandler(HttpContextBase context)
{
RequestData data = (RequestData)context.Items[_requestDataKey];
if (data != null)
{
context.RewritePath(data.OriginalPath);
context.Handler = data.Handler;
}
}
示例2: PostResolveRequestCache
/// <summary>
/// Finds the appropriate route for the specified
/// HTTP request and rewrites the execution path,
/// if necessary
/// </summary>
/// <param name="context">The current HTTP request context</param>
public virtual void PostResolveRequestCache(HttpContextBase context)
{
RouteData data = Routes.GetRouteData(context);
if (data == null)
return;
IRouteHandler handler = data.Handler;
if (handler == null)
throw Error.NoRouteHandlerFound();
if (handler is StopRoutingHandler) // если надо тормознуть, тормозим
return;
RequestContext requestContext = new RequestContext(context, data);
IHttpHandler httpHandler = handler.GetHttpHandler(requestContext);
if (httpHandler == null)
throw Error.NoHttpHandlerFound(handler.GetType());
context.Items[_requestDataKey] =
new RequestData(httpHandler, context.Request.Path);
context.RewritePath("~/wahha.routing.axd");
}