1
私はOWINの助けを借りて自己ホスト型のアプリケーションを持っています。また、いくつかの静的ファイルを提供する必要があります。それは動作しますが、最近私は問題に直面しました - デフォルトファイルは動作を停止しました。ローカルホストに行くと、メインページにリダイレクトされます。しかし、現在、メインページは直接経路のみでアクセス可能である。ここでhttps://localhost:4443/index.html
は私の起動方法である:OWIN静的ファイルを使用してメインページを定義する
public class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
public void Configuration(IAppBuilder appBuilder)
{
try
{
appBuilder.UseOAuthAuthorizationServer(new OAuthOptions());
appBuilder.UseJwtBearerAuthentication(new JwtOptions());
var config = new MyHttpsSelfHostConfiguration("https://localhost:4443");
var start = DateTime.Now;
config.MapHttpAttributeRoutes();
var jsonFormatter = new JsonMediaTypeFormatter();
config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
config.Routes.MapHttpRoute(
name: "WebLabApp",
routeTemplate: "api/{controller}/{action}/{id}"
);
ConfigureUnity(config);
appBuilder.UseWebApi(config);
Console.WriteLine($"Configure Unity in {DateTime.Now - start}");
start = DateTime.Now;
BusinessServicesHostLibrary.ContainerRegistry.RegisterAllBusinessServicesCommonClassesAndConnectionFactory();
Console.WriteLine($"Register all in {DateTime.Now - start}");
#if DEBUG
var contentDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent?.FullName;
#else
var contentDir = @".";
#endif
var fileSystem = new PhysicalFileSystem(contentDir);
var options = new FileServerOptions
{
EnableDefaultFiles = true,
DefaultFilesOptions = { DefaultFileNames = { "index.html" } },
FileSystem = fileSystem,
};
options.StaticFileOptions.FileSystem = fileSystem;
options.StaticFileOptions.ServeUnknownFileTypes = true;
appBuilder.UseFileServer(options);
config.EnsureInitialized();
}
catch (Exception ex)
{
if (ex is System.Reflection.ReflectionTypeLoadException)
{
var typeLoadException = ex as ReflectionTypeLoadException;
var loaderExceptions = typeLoadException.LoaderExceptions;
foreach (var x in loaderExceptions) Console.WriteLine(x);
}
throw;
}
}
私が間違って何をしているのですか?