My usual development stack is PHP, MySQL/Postgres on the server and the usual HTML/JS/CSS on the front. I’m looking to make a swap from PHP to F#, whilst keeping everything in tact.
I downloaded Rider (use PHPStorm usually so I figure less of a learning curve, but I have Visual Studio installed too). I have used .NET before (C#) to develop Windows Form Apps, so it’s been a while. I’m not married to .NET either, but I want to spend as little time setting up as possible.
So I simply loaded up Rider’s default web app template and…I’m lost. I need a bit of a baby’s first step guide to this.
Here’s the code in startup.fs:
namespace TestWeb open System open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Http open Microsoft.Extensions.DependencyInjection open Microsoft.Extensions.Hosting open System open System.IO type Startup() = // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 member _.ConfigureServices(services: IServiceCollection) = () // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. member _.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) = if env.IsDevelopment() then app.UseDeveloperExceptionPage() |> ignore let content = "Hello World" app.UseRouting() .UseEndpoints(fun endpoints -> endpoints.MapGet("/", fun context -> context.Response.WriteAsync(content)) |> ignore ) |> ignore
So I can see what the routing, but how do I set the content to be HTML. I usually use my own templating system in PHP, which opens a html file, parses it for variables etc and then echos the result. How do I approach that in .NET web development? I did try a ReadAllLines from a file and got nowhere, as there were type conflicts even when casting as a string.
What’s the best way to structure my filesystem? How do I include other F# files
Is there a resource for ground up Web Applications in F#? Looking to start with basic templating, SQL connection and maybe some XML manipulation.
Thank you for any help you can provide!