As a follow up to this: I've just found another potential issue after deployment of my service to http://localhost:9000/MyService.

The Main.html file contains references to js and css files, e.g. <link href="/Content/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> However, my browser tells me it couldn't find the file: http://localhost:9000/Content/css/bootstrap.min.css

(Mind the lack of "MyService" part).

When I modify the link by hand to http://localhost:9000/MyService/Content/css/bootstrap.min.css and navigate to it, I see the bootstrap css file, which proves it's there. However, my application keeps on searching for the file using the unshifted path.

At the moment I'm not sure if that's an issue with W# or with OWIN itself. I'll keep on looking into it, but please give it a thought as well.

By on 10/6/2015 6:24 AM ()

Actually I've worked out everything works fine if I add "~" to the href value: <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

By on 10/6/2015 7:57 AM ()

If you want one of the pages of the application to be served at /MyService, then you can just change the corresponding endpoint:

1
2
3
type EndPoint =
    | [<EndPoint "GET /MyService">] Home
    | [<EndPoint "GET /about">] About

If what you want is for the whole application to be under /MyService (ie. the About page would be at /MyService/about) then you can Shift the sitelet:

1
2
// ...
    .UseSitelet(rootDirectory, Sitelet.Shift "MyService" Site.Main)
By on 9/23/2015 3:17 AM ()

Yeah - but that still causes the application to use http://host:9000/, which is already taken by another service. In my design there are many microservices running on that port (http://host:9000/MyService1, http://host:9000/MyService2, ...) and there's also one service running exactly on host:9000.

That's why I'd like to start my app exactly on http://host:9000/MyService. Doing so in the following way:

1
2
3
4
5
use server = 
	WebApp.Start("http://host:9000/MyService", fun appB -> 
    	appB.UseStaticFiles( StaticFileOptions( FileSystem = PhysicalFileSystem(rootDirectory))) 
        .UseSitelet(rootDirectory, Sitelet.Shift "MyService" Site.Main) 
    |> ignore)

Causes the links to be generated as: http://host:9000/MyService/MyService/... . However - when I manually remove one of the "MyService" elements, the content gets displayed correctly.

By on 9/23/2015 5:05 AM ()

How are those existing services implemented? It is not possible for several applications to listen on the same port.

By on 9/23/2015 5:25 AM ()

Well, looks like OWIN somehow allows a user to do so. Here's my sample app:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
open Owin
open Microsoft.Owin.Hosting
open System

type Startup() =
    member this.Configuration(app : IAppBuilder) =
        app.UseWelcomePage() |> ignore

[<EntryPoint>]
let main argv = 
    let uri = "http://localhost:8080/Test/"
 
    use webApp = WebApp.Start<Startup>(uri)
    printfn "Started"
    System.Console.ReadKey() |> ignore
    printfn "Stopping"
    0

Launch two instances of it, but change the url of the other e.g. to http://localhost:8080/Test2/. There's no collision between these two.

I found an article that shows a bit different concept: http://www.strathweb.com/2013/05/the-future-is-now-owin-and-multi-hosting-asp-net-web-applications/

By on 9/23/2015 6:05 AM ()

Anyway - coming back to my question.

The piece of code I posted proves that it is possible to host an application using let url = "http: //host:9000/MyServiceName". However, adding this suffix "MyServiceName" causes a WebSharper app to go crazy. I've given a try to two cases:

1.) url = "http: //host:9000/MyServiceName"; no Sitlet.Shift I would expect to see a home page when using the url address. However, all I can see is a black page.

2.) url = "http: //host:9000/MyServiceName"; Sitlet.Shift = "MyServiceName Using url address shows the home site - that's ok. However, navigating to any other site using ctx.Link <ActionName> causes the link to be created as:

http: //host:9000/MyServiceName/MyServiceName/ActionName

If I remove one of the "MyServiceName" parts, then it works just fine.

So in my understanding the application always gets hosted at http://host:port/SitletShift, potentially ignoring part of the url provided by a user. When generating links using ctx.Link uses the user-provided url + shift. That sounds wrong to me.

By on 9/25/2015 2:53 AM ()

All right, I indeed found a bug in the WebSharper.Owin layer: the URL passed to the Sitelets parser is not stripped of the path base (/MyServiceName in your case). Here is the issue I filed, I'll fix it quickly.

By on 9/25/2015 6:17 AM ()

I've downloaded the most recent version from git, then compiled and linked it to my project. Looks like it solves the problem - well done!

Can't wait to see the newest version of NuGet package :). Thanks for the help!

By on 9/25/2015 6:47 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper