0
通過Fiddler向Kestrel發送請求時,以下請求成功。從仿真器發送請求時的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");
});
}
}
}
我會忍不住說這是一個錯誤的紅隼(試圖建立一個'PathString'爲空字符串不是合法的操作)。您應該可以通過嘗試從內聯中間件訪問'context.Request.Path'來確認它。 – Pinpoint
好的。會做。現在,爲什麼Kestrel會使用Firefox和Fiddler的請求,而不是來自NETMF的模擬器? –
在NETMF請求中使用的URI的末尾沒有結尾的斜槓。 – Pinpoint