2014-04-21 8 views
1

매개 변수가있는 미들웨어를 만들려고 시도하지만 http 504 오류 만 발생합니다. 이 코드는 매개 변수없이 잘 작동합니다.매개 변수가있는 katana/owin 미들웨어

어떤 아이디어가 있습니까?

public void Configuration(IAppBuilder app) 
{ 
    app.Use<MyMiddleware>("Hello"); 
} 

class MyMiddleware : OwinMiddleware 
{ 
    public MyMiddleware(OwinMiddleware next, string message) 
    : base(next) 
    { 
     Message = message; 
    } 

    public string Message { get; set; } 

    public override async Task Invoke(IOwinContext context) 
    { 
     context.Response.ContentLength = Message.Length; 
     context.Response.ContentType = "text/html"; 
     await context.Response.WriteAsync(Message); 
     await Next.Invoke(context); 
    } 
} 
+0

"hello Frédo"와 같은 문자열로만 문제가 추가되었음을 발견했습니다. 인코딩 문제가 있습니까? 어쨌든 이상한데. –

답변

0

제가

가 ContentLength 이렇게 UTF-8로 평가되어야 문제 발견 OK :

C 번호들이 UTF-16을 사용

Encoding.UTF8.GetBytes (메시지) .Length을 기본적으로 인코딩