C # Google OAUTH2 с использованием OWIN на Mono приводит к «System.Web.HttpException (0x80004005): заголовки уже отправлены» - PullRequest
0 голосов
/ 17 декабря 2018

Я следовал нескольким учебникам по добавлению аутентификации Google OAUTH2 в существующий проект MVC, но у меня возникла та же проблема, связанная с 404 для клиента и сгенерированная следующая трассировка:

System.Web.HttpException (0x80004005): headers have already been sent
  at System.Web.HttpResponse.set_StatusCode (System.Int32 value) [0x00012] in <d31574f4ab6745f49b1626160268508f>:0 
  at System.Web.HttpResponseWrapper.set_StatusCode (System.Int32 value) [0x00000] in <d31574f4ab6745f49b1626160268508f>:0 
  at Microsoft.Owin.Host.SystemWeb.OwinCallContext.Microsoft.Owin.Host.SystemWeb.CallEnvironment.AspNetDictionary.IPropertySource.SetResponseStatusCode (System.Int32 value) [0x00000] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.CallEnvironment.AspNetDictionary.set_ResponseStatusCode (System.Int32 value) [0x00000] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.CallEnvironment.AspNetDictionary.PropertiesTrySetValue (System.String key, System.Object value) [0x00257] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.CallEnvironment.AspNetDictionary.System.Collections.Generic.IDictionary<System.String,System.Object>.set_Item (System.String key, System.Object value) [0x00000] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.OwinResponse.Set[T] (System.String key, T value) [0x00006] in <0850b9daadb8416ca216d3d37f3983d1>:0 
  at Microsoft.Owin.OwinResponse.set_StatusCode (System.Int32 value) [0x00000] in <0850b9daadb8416ca216d3d37f3983d1>:0 
  at Microsoft.Owin.OwinResponse.Redirect (System.String location) [0x00000] in <0850b9daadb8416ca216d3d37f3983d1>:0 
  at Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationHandler.InvokeReplyPathAsync () [0x002c9] in <dcea7978bc3a4441882e0efa5daced72>:0 
  at Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationHandler.InvokeAsync () [0x00068] in <dcea7978bc3a4441882e0efa5daced72>:0 
  at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[TOptions].Invoke (Microsoft.Owin.IOwinContext context) [0x00109] in <1cc66b39b04f4b919683032a3a12cc4f>:0 
  at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp (System.Func`2[T,TResult] entryPoint, System.Collections.Generic.IDictionary`2[TKey,TValue] environment, System.Threading.Tasks.TaskCompletionSource`1[TResult] tcs, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult result) [0x0007e] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[TOptions].Invoke (Microsoft.Owin.IOwinContext context) [0x00183] in <1cc66b39b04f4b919683032a3a12cc4f>:0 
  at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[TOptions].Invoke (Microsoft.Owin.IOwinContext context) [0x00183] in <1cc66b39b04f4b919683032a3a12cc4f>:0 
  at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp (System.Func`2[T,TResult] entryPoint, System.Collections.Generic.IDictionary`2[TKey,TValue] environment, System.Threading.Tasks.TaskCompletionSource`1[TResult] tcs, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult result) [0x0007e] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.DoFinalWork (Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult result) [0x0007d] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.Rethrow () [0x00000] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End (System.IAsyncResult ar) [0x0001d] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork (System.IAsyncResult ar) [0x00006] in <90ddfcf805444e2e8c4aafed95112b04>:0 
  at System.Web.AsyncInvoker.<doAsyncCallback>b__8_0 (System.Object ores) [0x00007] in <d31574f4ab6745f49b1626160268508f>:0 

Я использую моно в Linux, и я предполагаю, что это как-то связано с системой web.config или маршрутизацией.Я видел похожие вопросы / ответы, но ничего, что я читал, не относится к этой точной ошибке.Нужно ли отменить регистрацию модуля или какой-либо другой вариант, который может быть причиной этого?

...