17
Owin을 사용하여 파일 요청과 웹 API를 모두 지원하는 자체 호스팅 서버를 구축하고 있습니다. 그러나 웹 API 요청의 출력은 항상 xml 형식입니다. json에서 출력 할 owin을 어떻게 구성 할 수 있습니까?Owin 자체 호스트 지원 Json 출력을 만드는 방법은 무엇입니까?
코드는 다음과 같습니다 :
class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseFileServer(new FileServerOptions()
{
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@".\files")
});
// set the default page
app.UseWelcomePage(@"/index.html");
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute
(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
app.UseWebApi(config);
}
}
XML로 결과를 요청하면 어떤 헤더를 보내고 있습니까? JSON을 지정하는'Accept' 헤더를 보내고 있습니까? – David
헤더는 아래와 같습니다 : Accept : text/html, application/xhtml + xml, application/xml, q = 0.9, image/webp, */*; q = 0.8 –