ServiceStack self-host workaround for VirtualPathUtility exception. If you're self-hosting recent versions of ServiceStack (3.9.45+) and serving Razor views, you'll notice that @href (which is a wrapper around Url.Content) fails with app-relative paths that start with "~/". Add the following to your startup code to work around it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|var domain = Thread.GetDomain(); // or AppDomain.Current|
|if (String.IsNullOrWhiteSpace(domain.GetData(".appId") as string))|
|if (String.IsNullOrWhiteSpace(domain.GetData(".domainId") as string))|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Thx for this info, it turns out this was the cause of Razor not working too well on Mono/HttpListener, so I've now baked it in to v3.9.48.
I pre-populate this info by default on HttpListenerBase.SetAppDomainData which can also be overridden if anyone doesn't like this default behavior.