Skip to content

Commit 85b45e1

Browse files
committedMay 29, 2013
Added overridable HttpListenerBase.SetAppDomainData to populate AppDomain with required data required to construct urls
1 parent 84774b2 commit 85b45e1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed
 

‎src/ServiceStack/WebHost.Endpoints/Support/HttpListenerBase.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,31 @@ public void Init()
8585
}
8686

8787
EndpointHost.AfterInit();
88-
88+
SetAppDomainData();
89+
8990
var elapsed = DateTime.UtcNow - this.startTime;
9091
Log.InfoFormat("Initializing Application took {0}ms", elapsed.TotalMilliseconds);
9192
}
9293

9394
public abstract void Configure(Container container);
9495

96+
public virtual void SetAppDomainData()
97+
{
98+
//Required for Mono to resolve VirtualPathUtility and Url.Content urls
99+
var domain = Thread.GetDomain(); // or AppDomain.Current
100+
domain.SetData(".appDomain", "1");
101+
domain.SetData(".appVPath", "/");
102+
domain.SetData(".appPath", domain.BaseDirectory);
103+
if (string.IsNullOrEmpty(domain.GetData(".appId") as string))
104+
{
105+
domain.SetData(".appId", "1");
106+
}
107+
if (string.IsNullOrEmpty(domain.GetData(".domainId") as string))
108+
{
109+
domain.SetData(".domainId", "1");
110+
}
111+
}
112+
95113
/// <summary>
96114
/// Starts the Web Service
97115
/// </summary>

0 commit comments

Comments
 (0)
Please sign in to comment.