Changing the virtual path for static content

I am working on a project, which is a site consisting of self-hosting, hosting 2 separate "plugins". I am trying to configure it so that I can serve my static content files from the plugin directories so that I can edit them on the go during debugging and not have to reinstall to copy chages to the bin directory.

I already have this work for my razor files by adding this:

Plugins.Add(new RazorFormat { VirtualPathProvider = new FileSystemVirtualPathProvider(this, "../../../Project1") }); Plugins.Add(new RazorFormat { VirtualPathProvider = new FileSystemVirtualPathProvider(this, "../../../Project2") }); 

I cannot figure out how to do the same for my static content files. It seems that I could fix one project at a time by adding EndpointHostConfig.Instance.WebHostPhysicalPath = "../../../ProjectName"; but not both at the same time. Is there a way to establish a virtual path provider for all served files, not just razor files?

+1
servicestack static-content
source share
1 answer

ServiceStack has not switched to using VirtualPathProvider to process the contents of static files.

The request for a static file is determined at the beginning of the ASP.NET request pipeline (i.e., before it reaches ServiceStack IHttpHandler) at the point where the VirtualPathProvider permission is not ideal (for example, a connection).

We are currently exploring the implications of using a virtual path because it invalidates the physical path expected by the host web server.

Overriding ServiceStack Default Behavior

the first 2 hooks in the ServiceStack operation order allow you to enter custom logic and handle static file requests to override the default behavior in ServiceStack, both are configured in AppHost.Configure() , and in both cases you can return IHttpHandler if you want to execute a hello request:

1) Config.RawHttpHandlers:

 SetConfig(new EndpointHostConfig { RawHttpHandlers = { (httpReq) => ... }, }); 

2) IAppHost.CatchAllHandlers:

 this.CatchAllHandlers.Add((httpMethod, pathInfo, filePath) => ...); 
+2
source share

All Articles