Class ClientSyncContentController
MVC controller for handling update content requests from Windows clients
Inheritance
System.Object
Microsoft.AspNetCore.Mvc.ControllerBase
Microsoft.AspNetCore.Mvc.Controller
ClientSyncContentController
Implements
Microsoft.AspNetCore.Mvc.Filters.IActionFilter
Microsoft.AspNetCore.Mvc.Filters.IAsyncActionFilter
Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata
System.IDisposable
Namespace: Microsoft.UpdateServices.ClientSync.Server
Assembly: client-server-sync-lib.dll
Syntax
public class ClientSyncContentController : Controller, IActionFilter, IAsyncActionFilter, IFilterMetadata, IDisposable
Examples
Attach this service to your ASP.NET service:
public void ConfigureServices(IServiceCollection services)
{
var localMetadataSource = CompressedMetadataStore.Open(sourcePath);
var contentSource = new FileSystemContentStore(contentPath);
services.TryAddSingleton<ClientSyncContentController>(
new ClientSyncContentController(localMetadataSource, contentSource));
//
// Add ClientSyncContentController from its containing assembly
services
.AddMvc()
.AddApplicationPart(
Assembly.Load(
"Microsoft.UpdateServices.ClientSync.Server.ClientSyncContentController"))
.AddControllersAsServices();
...
}
// Configure routes for the content controller
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Add the content controller to MVC route
app.UseMvc(routes =>
{
routes.MapRoute(
name: "getContent",
template: "Content/{directory}/{name}",
defaults: new
{
controller = "ClientSyncContent",
action = "GetUpdateContent"
});
});
...
}
Constructors
ClientSyncContentController(IMetadataSource, IUpdateContentSource)
Create a content controller from the specified metadata and update content sources.
Declaration
public ClientSyncContentController(IMetadataSource metadataSource, IUpdateContentSource contentSource)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.UpdateServices.Storage.IMetadataSource | metadataSource | The source of update metadata. Used to build the list of known files to serve. |
Microsoft.UpdateServices.Storage.IUpdateContentSource | contentSource | The source of content. Used to read update content and send it to clients. |
Methods
GetUpdateContent(String, String)
Handle HTTP GET requests on the Content/(Directory)/(FileHash) URLs
Declaration
[HttpGet("Content/{directory}/{name}", Name = "GetUpdateContent")]
public IActionResult GetUpdateContent(string directory, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | directory | The directory name for an update file |
System.String | name | The file name for an update file |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.IActionResult | File content on success, other error codes otherwise |
GetUpdateContentHead(String, String)
Handle HTTP HEAD requests on the Content/(Directory)/(FileName) URLs
Declaration
[HttpHead("Content/{directory}/{name}", Name = "GetUpdateContentHead")]
public void GetUpdateContentHead(string directory, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | directory | The directory name for an update file |
System.String | name | The file name for an update file |
Implements
Microsoft.AspNetCore.Mvc.Filters.IActionFilter
Microsoft.AspNetCore.Mvc.Filters.IAsyncActionFilter
Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata
System.IDisposable