asp.net-mvc - ASPX 中的重复方法 'ProcessRequest'

标签 asp.net-mvc f#

我正在尝试在 F# 中编写 ASP.NET MVC View (WebForms View 引擎)。我已经可以编写常规的 ASP.NET WebForms ASPX 并且它工作正常,例如

<%@ Page Language="F#" %>
<%
for i in 1..2 do %>
<%=sprintf "%d" i %>

所以我假设我的 web.config 中的所有内容都已正确设置。

但是,当我使页面从 ViewPage 继承时:
<%@ Page Language="F#" Inherits="System.Web.Mvc.ViewPage" %>

我收到此错误:

Compiler Error Message: FS0442: Duplicate method. The abstract method 'ProcessRequest' has the same name and signature as an abstract method in an inherited type.



问题似乎是由 F# CodeDom 提供程序生成的这段代码:
[<System.Diagnostics.DebuggerNonUserCodeAttribute>]
abstract ProcessRequest : System.Web.HttpContext -> unit
[<System.Diagnostics.DebuggerNonUserCodeAttribute>]
default this.ProcessRequest  (context:System.Web.HttpContext) =
    let mutable context = context
    base.ProcessRequest(context) |> ignore

当我将 Page 指令更改为使用 C# 时,生成的代码是:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public new virtual void ProcessRequest(System.Web.HttpContext context) {
    base.ProcessRequest(context);
}

这当然可以正常工作,而且 AFAIK 在语义上与生成的 F# 代码不同。

我正在使用 .NET 4.0.30319.1 (RTM) 和 MVC 2 RTM

最佳答案

不幸的是,我不确定是否有任何方法可以声明 new virtual F# 中的成员。快速浏览一下规范并没有发现任何有希望的东西......

关于asp.net-mvc - ASPX 中的重复方法 'ProcessRequest',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2726929/

相关文章:

c# - Html.EnumDropDownListFor 根据枚举变量的值设置选定的列表项

f# - 为什么这个 F# 计算表达式会给出警告?

windows - F# 使用 WinForms 拖放 : DragDrop event of a control does not call the referenced member function

.net - 在 F# 中强制任何对象为 null

parsing - 递归解析语法消耗输入并且无法解析序列

javascript - 在 razor foreach 语句中调用 JavaScript 函数

c# - 在 Controller 内部调用 void 函数

ASP.NET-MVC2 : Why does TryUpdateModel ignore properties after the second level of the object model tree?

c# - 如何在 MVC 中填充模型

algorithm - F# 中的广度优先搜索 (BFS)