Domanda

I am trying to use Servicestack with F#. So, far I am successful. But while trying to pull thing up with asp.net hosting using razor engine. I come across weird issue.

If for default.cshtml I choose property that do not copy with compilation with content than page is not getting populated and it is going to metadata page. But if I set to copy if newer it will work.

But as far as I know this should be do not copy only as compilation is content. If we are not doing that then for every change in cshtml page there is need to re-run the project.

Now, this is also unique to F# project, in C# it is working. So, I exactly don't know where to look. BTW I am using 3.9.71 version of servciestack.

Please let me know if any further details is needed. My project repo

È stato utile?

Soluzione

Update:

Your application is setup incorrectly.

Your F# MVC application isn't setup properly. You are using ASP.NET which should use IIS as its host. Which means the requests from IIS get passed into the AppHost. However in your setup you are using an AppHostHttpListenerBase this is actually creating it's own HTTP Listener, essentially you have mixed the Standalone Self Hosting with ASP.NET hosted setup.

As a result you are getting the odd situation of having to copy the content to the output directory. That's because in a standalone ServiceStack app, that is the requirement, it's looking for the content in the wrong place.

Try using this:

type AppHost =
    inherit AppHostBase
    new() = { inherit AppHostBase("Hello F# Services", typeof<HelloService>.Assembly) }
    override this.Configure container =
    ...

You should read this article to ensure you have setup the MVC ASP.NET application correctly.

You will still want to use DebugMode = true to enable ServiceStack to automatically pick up on changes, so I have left that part of the answer in.


It's a little hard to follow what you are saying, but if I have interpreted it correctly, you are saying you have an F# ASP.NET ServiceStack Razor project and you are finding that you are having to re-run the build process every time you make changes to your Views.

I haven't used F# yet so I will have to give the example in C# but you need to set your AppHost config to DebugMode = true in order to have ServiceStack automatically pick up on the changes, and thus you won't have to re-run the build process each time.

SetConfig(new EndpointHostConfig {
    DebugMode = true,
});

I notice in your code that this is not set:

type AppHost() = 
    inherit AppHostHttpListenerBase("Hello F# Service", typeof<HelloService>.Assembly)
    override this.Configure container =
        this.Plugins.Add(new RazorFormat()) 
        ignore()
   
    static member start() = 
        let apphost = new AppHost()
        apphost.Init()

See the section "Automatic reload of modified views, layout templates and partials (in Debug mode)" in this documentation for more information.

So in Debug Mode we'll also do this where a background file system watcher monitors all pages, partials and Layout templates for modifications and recompiles and auto-reloads them on the fly ...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top