forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppHostBase.cs
More file actions
37 lines (33 loc) · 1.26 KB
/
Copy pathAppHostBase.cs
File metadata and controls
37 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Reflection;
using System.Web;
using System.Web.Hosting;
using ServiceStack.Host.AspNet;
using ServiceStack.Web;
namespace ServiceStack
{
/// <summary>
/// Inherit from this class if you want to host your web services inside an
/// ASP.NET application.
/// </summary>
public abstract class AppHostBase : ServiceStackHost
{
protected AppHostBase(string serviceName, params Assembly[] assembliesWithServices)
: base(serviceName, assembliesWithServices) { }
public override string ResolveAbsoluteUrl(string virtualPath, IHttpRequest httpReq)
{
if (HostingEnvironment.ApplicationVirtualPath != null
&& virtualPath.StartsWith("~" + HostingEnvironment.ApplicationVirtualPath))
{
virtualPath = virtualPath.Remove(1, HostingEnvironment.ApplicationVirtualPath.Length);
}
return Config.WebHostUrl == null
? VirtualPathUtility.ToAbsolute(virtualPath)
: httpReq.GetAbsoluteUrl(virtualPath);
}
public override string ResolvePhysicalPath(string virtualPath, IHttpRequest httpReq)
{
var path = ((AspNetRequest)httpReq).Request.PhysicalPath;
return path;
}
}
}