【问题标题】:MvcHttpHandler doesn't seem to implement IHttpHandlerMvcHttpHandler 似乎没有实现 IHttpHandler
【发布时间】:2010-01-16 13:21:27
【问题描述】:

我正在尝试为 MVC 控制器执行自定义 ActionResult。在我正在查看的示例中,它显示了下面的 sn-p。我的 System.Web.Mvc.MvcHttpHandle 没有实现 IHttpHandler 接口。 System.Web.Mvc.dll 是版本 1.0.0.0。我应该只编写自己的 httphandler,还是需要在 Controller ActionResult 中使用特定于 MvcHttpHandler 的东西?

/// <summary>
/// Transfers execution to the supplied url.
/// </summary>
public class TransferResult : RedirectResult
{
    public TransferResult(string url)
        : base(url)
    {
    }

    public override void ExecuteResult(ControllerContext context)
    {
        var httpContext = HttpContext.Current;

        httpContext.RewritePath(Url, false);

        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current);
    }
}

谢谢,

~B

【问题讨论】:

  • 这段代码编译了吗?

标签: c# asp.net-mvc


【解决方案1】:

我想出了一个解决方案

我变了:

IHttpHandler httpHandler = new MvcHttpHandler();

到:

IHttpHandler httpHandler = new MvcHandler(context.RequestContext);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    相关资源
    最近更新 更多