开发者

Duplicate method 'ProcessRequest' in ASPX

开发者 https://www.devze.com 2022-12-28 04:53 出处:网络
I\'m trying to code ASP.NET MVC views (WebForms view engine) in F#. I can already write regular ASP.NET WebForms ASPX and it works ok, e.g.

I'm trying to code ASP.NET MVC views (WebForms view engine) in F#. I can already write regular ASP.NET WebForms ASPX and it works ok, e.g.

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

so I assume I have everything in my web.config correctly set up.

However, when I make the page inherit from ViewPage:

<%@ Page Language="F#" Inherits="System.Web.Mvc.ViewPage" %>

I get this error:

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

The problem seems to be this piece of code generated by the F# CodeDom provider:

[<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

when I cha开发者_C百科nge the Page directive to use C# instead, the generated code is:

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public new virtual void ProcessRequest(System.Web.HttpContext context) {
    base.ProcessRequest(context);
}

which of course works fine and AFAIK is not semantically the same as the generated F# code.

I'm using .NET 4.0.30319.1 (RTM) and MVC 2 RTM


Unfortunately, I'm not sure if there is any way to declare a new virtual member in F#. A quick look through the spec didn't turn up anything promising...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号