如何设置 owinstartup 属性?

How do I set the owinstartup attribute?

我阅读了 F# 中的 similar problem,但似乎无法在此处应用答案。

我有非常简单的代码,给出了与链接问题相同的错误。 "This is not a valid constant expression or custom attribute value."

namespace MyNamespace
open Microsoft.Owin
open Owin

type Startup() = 
    member x.Foo() = ()
    member x.ConfigureAuth (app : IAppBuilder) = 
        //app.CreatePerOwinContext()
        ()
[<assembly: OwinStartup(typeof<StartUp>)>]
    do ()

可以定义多个 file/class 程序集属性吗? 如果不是,将 assemblyinfo.fs 文件移近项目底部是否可以(不脏)?

最大的问题,我如何编译它?

如果您添加 member __.Configuration 它应该会自动检测到它:

namespace MyNamespace
open Microsoft.Owin
open Owin

type Startup() = 
    member x.Foo() = ()
    member x.ConfigureAuth (app : IAppBuilder) = 
        //app.CreatePerOwinContext()
        ()

    member x.Configuration (app: IAppBuilder) =
        app.Run(fun c -> c.Response.WriteAsync("Hello maslow!"))

此外,如果您指定参数,这也有效:

[<assembly: Microsoft.Owin.OwinStartup(startupType = typeof<Startup>)>]
do ()

我可能会坚持使用看起来有点不同的 Startup.fs 文件:

namespace MyNamespace
open Owin
open Microsoft.Owin

type Startup() = 
    let configureAuth (app: IAppBuilder) = 
        //app.CreatePerOwinContext()
        ()

    member __.Configuration (app: IAppBuilder) =
        configureAuth app
        app.Run(fun c -> c.Response.WriteAsync("Hello maslow!"))