Ich habe den REST -API -Dienst im Dotnet Core erstellt. Die Anwendungsendpunkte funktionieren einwandfrei, wenn ich aus dem Code ausgeführt werde, aber nachdem ich ihn auf dem IIS -Server veröffentlicht habe, wenn ich versuche, darauf zuzugreifen, gibt es mir die folgende Fehlerantwort < /p>
{
"StatusCode": 500,
"Message": "An unexpected error occurred. Please try again later.",
"Details": "The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true."
}
< /code>
Ich habe nach zu vielen Lösungen gesucht, aber für mich funktioniert nichts.
Ich habe einfach eine Website in IIS erstellt. Seine Anwendungspool hinzugefügt, binden Sie ihn richtig, aber immer noch kein Glück.public class ExceptionHandlingMiddleware
{
private readonly RequestDelegate _next;
public ExceptionHandlingMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
try
{
await _next(context); // Call the next middleware
}
catch (Exception ex)
{
await HandleExceptionAsync(context, ex);
}
}
private static Task HandleExceptionAsync(HttpContext context, Exception exception)
{
// Log the exception (optional)
Console.WriteLine($"Exception: {exception.Message}");
var response = new
{
StatusCode = (int)HttpStatusCode.InternalServerError,
Message = "An unexpected error occurred. Please try again later.",
Details = exception.Message // Include more details for development environment
};
context.Response.ContentType = "application/json";
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
return context.Response.WriteAsync(JsonSerializer.Serialize(response));
}
}
Ich habe den REST -API -Dienst im Dotnet Core erstellt. Die Anwendungsendpunkte funktionieren einwandfrei, wenn ich aus dem Code ausgeführt werde, aber nachdem ich ihn auf dem IIS -Server veröffentlicht habe, wenn ich versuche, darauf zuzugreifen, gibt es mir die folgende Fehlerantwort < /p> [code]{ "StatusCode": 500, "Message": "An unexpected error occurred. Please try again later.", "Details": "The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true." } < /code> Ich habe nach zu vielen Lösungen gesucht, aber für mich funktioniert nichts. Ich habe einfach eine Website in IIS erstellt. Seine Anwendungspool hinzugefügt, binden Sie ihn richtig, aber immer noch kein Glück.public class ExceptionHandlingMiddleware { private readonly RequestDelegate _next;
public ExceptionHandlingMiddleware(RequestDelegate next) { _next = next; }
public async Task InvokeAsync(HttpContext context) { try { await _next(context); // Call the next middleware } catch (Exception ex) { await HandleExceptionAsync(context, ex); } }
var response = new { StatusCode = (int)HttpStatusCode.InternalServerError, Message = "An unexpected error occurred. Please try again later.", Details = exception.Message // Include more details for development environment };
Ich habe den REST -API -Dienst im Dotnet Core erstellt. Die Anwendungsendpunkte funktionieren einwandfrei, wenn ich aus dem Code ausgeführt werde, aber nachdem ich ihn auf dem IIS -Server...
Ich bekomme wirklich Probleme beim Lösen von 500 internen Fehler in Restapi. Wenn ich versuche, eine Anfrage zu stellen, werden 500 interne Fehler angezeigt. Ich weiß nicht, warum es passiert, also...
Ich versuche, ein ASP.NET -Kern -Web -API -Projekt in meinem Linux -System (Ubuntu 22.04) zu erstellen und mit dem Befehl dotnet restore oder dotnet New ein Problem zu stellen: Der Prozess bleibt...
Ich habe eine DotNet 8 ASP -Kernanwendung und ich versuche, mit ASPNetCore einen HealthCheck für meine Azure -Datenbank mit ASPNetCore.HealthChecks.mysql Nuget und Retrevers -Verbindungszeichenfolge...
Ich habe eine Laravel -Website entwickelt und auf den Live -Server hochgeladen. Da eine Laravel -Website nicht direkt auf dem gemeinsam genutzten Hosting gehostet werden kann, habe ich in der Datei...