本文整理汇总了C#中System.Web.Mvc.MvcHttpHandler类的典型用法代码示例。如果您正苦于以下问题:C# MvcHttpHandler类的具体用法?C# MvcHttpHandler怎么用?C# MvcHttpHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MvcHttpHandler类属于System.Web.Mvc命名空间,在下文中一共展示了MvcHttpHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
public void Page_Load(object sender, System.EventArgs e)
{
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
}
示例2: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
//Get url
string url = "";
if (!string.IsNullOrEmpty(_url)) url = _url;
else
{
//Create route
var routeValues = new RouteValueDictionary(_Values);
routeValues.Add("Action", _Action);
routeValues.Add("Controller", _Controller);
//Must persist ajax
var request = HttpContext.Current.Request;
if ((request["X-Requested-With"] != null &&
request["X-Requested-With"].Equals("XmlHttpRequest", StringComparison.InvariantCultureIgnoreCase)) ||
request.QueryString["_"] != null ||
context.HttpContext.Items["__IsAjaxRequest"] != null)
routeValues.Add("X-Requested-With", "XmlHttpRequest");
url = RouteTable.Routes.GetVirtualPath(context.RequestContext, routeValues).VirtualPath;
}
HttpContext.Current.RewritePath(url, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
//httpContext.Server.TransferRequest(url, true);
}
示例3: ServerTransferToRoute
/// <summary>
/// Redirect to another route using a server side transfer (so the client URL does not change)
/// </summary>
/// <param name="context"></param>
/// <param name="routeValues"></param>
private void ServerTransferToRoute(ActionExecutingContext context, object routeValues)
{
var httpContextBase = context.HttpContext;
var rc = new RequestContext(httpContextBase, context.RouteData);
string url = RouteTable.Routes.GetVirtualPath(rc,
new RouteValueDictionary(routeValues)).VirtualPath;
// MVC 3 running on IIS 7+
if (HttpRuntime.UsingIntegratedPipeline)
{
httpContextBase.Server.TransferRequest(url, true);
}
else
{
// Pre IIS7
// Get the current application to get the real HttpContext
var app = (HttpApplication)httpContextBase.GetService(typeof(HttpApplication));
// Rewrite the path of the request
httpContextBase.RewritePath(url, false);
// Process the modified request
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(app.Context);
}
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string path = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath,false);
IHttpHandler handler = new System.Web.Mvc.MvcHttpHandler();
handler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(path);
}
示例6: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
var httpContext = HttpContext.Current;
httpContext.RewritePath(Url, true);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
}
示例7: Page_Load
public void Page_Load(object sender, System.EventArgs e) {
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
示例8: OnLoad
/// <summary>
/// Raises the page's Load event.
/// </summary>
/// <param name="e">The event arguments.</param>
protected override void OnLoad(EventArgs e)
{
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
base.OnLoad(e);
}
示例9: Application_Error
protected void Application_Error(object sender, EventArgs eventArgs)
{
if (!HttpContext.Current.IsCustomErrorEnabled)
{
// Don't handle the error in this case.
return;
}
var exception = HttpContext.Current.Server.GetLastError();
exception = exception == null ? exception : exception.GetBaseException();
// Log the error here in some way. This example uses ELMAH so logging is handled via a module.
var appRelativePath = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
if (appRelativePath.StartsWith("~/" + ErrorControllerName + "/", StringComparison.OrdinalIgnoreCase))
{
TransferToFatalErrorPage();
return;
}
const string errorRoute = "~/" + ErrorControllerName + "/ServerError";
try
{
if (HttpRuntime.UsingIntegratedPipeline)
{
// For IIS 7+
HttpContext.Current.Server.TransferRequest(errorRoute, false, "GET", null);
}
else
{
// For IIS 6
var originalPath = HttpContext.Current.Request.Path;
HttpContext.Current.RewritePath(errorRoute);
IHttpHandler handler = new MvcHttpHandler();
handler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath);
HttpContext.Current.Server.ClearError();
}
}
catch (Exception)
{
// Log the error here in some way.
TransferToFatalErrorPage();
}
}
示例10: Page_Load
public void Page_Load(object sender, System.EventArgs e)
{
// 改变当前路径路由处理程序可以正确解释请求,
// 然后恢复原来的路径,以便在OutputCache模块
// 可以正确处理响应(如果缓存已启用).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
示例11: Transfer
public static void Transfer(ControllerContext filterContext, string url)
{
lock (objectTransfer)
{
// Rewrite path
HttpContext.Current.RewritePath(GetPath(filterContext, url), false);
IHttpHandler httpHandler = new System.Web.Mvc.MvcHttpHandler();
// Process request
httpHandler.ProcessRequest(HttpContext.Current);
filterContext.HttpContext.Response.End();
}
}
示例12: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
// MVC 3 running on IIS 7+
if (HttpRuntime.UsingIntegratedPipeline)
{
context.HttpContext.Server.TransferRequest(_url);
//context.HttpContext.Server.TransferRequest(_url, true);
}
else
{
// Pre MVC 3
context.HttpContext.RewritePath(_url, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(context.HttpContext.ApplicationInstance.Context);
}
}
示例13: Page_PreInit
protected void Page_PreInit(object sender, System.EventArgs e)
{
string url = "/";
var httpContext = HttpContext.Current;
//MVC 3 running on IIS 7+
if (HttpRuntime.UsingIntegratedPipeline)
{
httpContext.Server.TransferRequest(url, true);
}
else
{
// Pre MVC 3
httpContext.RewritePath(url, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(httpContext);
}
}
示例14: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
using (new TransactionScope(TransactionScopeOption.RequiresNew)) {
var httpContext = HttpContext.Current;
// See http://stackoverflow.com/questions/799511/how-to-simulate-server-transfer-in-asp-net-mvc/799534
// MVC 3 running on IIS 7+
if (HttpRuntime.UsingIntegratedPipeline) {
httpContext.Server.TransferRequest(Url, true);
}
else {
// Pre MVC 3
httpContext.RewritePath(Url, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(httpContext);
}
}
}
示例15: Application_Error
void Application_Error(object sender, EventArgs e)
{
var error = Server.GetLastError();
var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500;
if (code != 404)
{
//
}
Response.Clear();
Server.ClearError();
string path = Request.Path;
Context.RewritePath(string.Format("~/Errors/Http{0}", code), false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(Context);
Context.RewritePath(path, false);
}