add webtestversion
This commit is contained in:
88
Project/Web/Startup.cs
Normal file
88
Project/Web/Startup.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.StaticFiles;
|
||||
using Owin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Routing;
|
||||
using Project.Web.Controllers;
|
||||
|
||||
namespace Project.OWIN
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void Configuration(IAppBuilder app)
|
||||
{
|
||||
// Configure Web API for Self-Host
|
||||
HttpConfiguration config = new HttpConfiguration();
|
||||
|
||||
//라우팅 설정
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{action}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
// JSON 포맷터 설정
|
||||
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||
|
||||
// 파일 업로드 설정
|
||||
config.Formatters.Remove(config.Formatters.XmlFormatter);
|
||||
|
||||
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
|
||||
app.UseWebApi(config);
|
||||
|
||||
// 정적 파일 서빙 설정
|
||||
var options = new FileServerOptions
|
||||
{
|
||||
EnableDefaultFiles = true,
|
||||
DefaultFilesOptions = { DefaultFileNames = { "index.html" } },
|
||||
FileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("Web/wwwroot")
|
||||
};
|
||||
|
||||
app.UseFileServer(options);
|
||||
|
||||
// 캐시 방지 미들웨어 추가
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
if (context.Request.Path.Value.EndsWith(".js") || context.Request.Path.Value.EndsWith(".css"))
|
||||
{
|
||||
context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
||||
context.Response.Headers["Pragma"] = "no-cache";
|
||||
context.Response.Headers["Expires"] = "0";
|
||||
}
|
||||
await next();
|
||||
});
|
||||
|
||||
//appBuilder.UseFileServer(new FileServerOptions
|
||||
//{
|
||||
// RequestPath = new PathString(string.Empty),
|
||||
// FileSystem = new PhysicalFileSystem("./MySubFolder"),
|
||||
// EnableDirectoryBrowsing = true,
|
||||
//});
|
||||
|
||||
//appBuilder.UseStageMarker(PipelineStage.MapHandler);
|
||||
|
||||
|
||||
//config.Routes.MapHttpRoute(
|
||||
// name: "ignore",
|
||||
// routeTemplate: @".*\.(css|js|gif|jpg)(/.*)?",
|
||||
// defaults: new
|
||||
// {
|
||||
// controller = "file",
|
||||
// action = "readtext",
|
||||
// id = RouteParameter.Optional
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user