0

Fiddler 経由で Kestrel にリクエストを行うと、次のリクエストが成功します。

GET http://192.168.1.148:5000/ HTTP/1.1
Host: 192.168.1.148:5000
Connection: keep-alive

NETMF エミュレーターを介して要求を行うと、次の要求は失敗します。

GET http://192.168.1.148:5000 HTTP/1.1
Host: 192.168.1.148:5000
Connection: keep-alive

これは ASP.NET Core エラー メッセージです。エラーはロギングに関するものと思われます。

Request finished in 24788.6203ms 500
fail: Microsoft.AspNet.Server.Kestrel[13]
An unhandled exception was thrown by the application.
System.AggregateException: An error occurred while writing to logger(s).

---> System.ArgumentException: Parameter name: value

at Microsoft.AspNet.Http.PathString..ctor(String value)
at Microsoft.AspNet.Http.Internal.DefaultHttpRequest.get_Path()
at Microsoft.AspNet.Hosting.Internal.HostingLoggerExtensions
    .HostingRequestStarting.ToString()
at Microsoft.Extensions.Logging.Console.ConsoleLogger.Log(
    LogLevel logLevel, Int32 eventId, Object state, 
    Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger.Log(
    LogLevel logLevel, Int32 eventId, Object state, 
    Exception exception, Func`3 formatter)

--- End of inner exception stack trace ---

at Microsoft.Extensions.Logging.Logger.Log(
    LogLevel logLevel, Int32 eventId, Object state, 
    Exception exception, Func`3 formatter)
at Microsoft.AspNet.Hosting.Internal.HostingLoggerExtensions
    .RequestStarting(ILogger logger, HttpContext httpContext)
at Microsoft.AspNet.Hosting.Internal.HostingEngine
    .<>c__DisplayClass32_0.<<Start>b__0>d.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter
    .HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Server.Kestrel.Http.Frame
    .<RequestProcessingAsync>d__79.MoveNext()

---> (Inner Exception #0) System.ArgumentException: Parameter name: value

at Microsoft.AspNet.Http.PathString..ctor(String value)
at Microsoft.AspNet.Http.Internal.DefaultHttpRequest.get_Path()
at Microsoft.AspNet.Hosting.Internal.HostingLoggerExtensions
    .HostingRequestStarting.ToString()
at Microsoft.Extensions.Logging.Console.ConsoleLogger.Log(
    LogLevel logLevel, Int32 eventId, Object state, 
    Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger.Log(
    LogLevel logLevel, Int32 eventId, Object state, 
    Exception exception, Func`3 formatter)<---

これは、ASP.NET Core プログラム全体です。

using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.Logging;

namespace EmptyApplication01
{
    public class Startup
    {
        public void Configure(
            IApplicationBuilder app, 
            ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Verbose);

            app.Run(async (context) =>
            {
                var logger = loggerFactory.CreateLogger("CatchAll");
                logger.LogInformation(DateTime.Now.ToString());

                await context.Response.WriteAsync("head, body");
            });
        }
    }
}
4

2 に答える 2

1

私は理解しました。AbsoluteURL がパスにある場合、Kestrel は壊れます。それを機能させるために、これは回避策です

    app.Use(next => async context => {

                 // get the frame from kestrel and then but the path by removing the hostname 
                var Frame = (Microsoft.AspNet.Server.Kestrel.Http.Frame)context.Features;

                var newpath = Frame.RequestUri.Replace("http://" + context.Request.Host.Value, "");
                context.Request.Path = newpath;

                // Invoke the rest of the pipeline.
                await next(context);

    });
于 2016-04-06T22:28:53.390 に答える
0

ログをオフにすると問題が解決しました。これはおそらく、ASP.NET ロギングの実装のバグです。

using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using System;

namespace EmptyApplication01
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(async (context) =>
            {
                // no more logging!
                System.Console.WriteLine(DateTime.Now.ToString());
                await context.Response.WriteAsync("head, body");
            });
        }
    }
}
于 2016-02-18T22:51:35.837 に答える