我正在尝试在 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/