I want to handle Error StatusCode in asp.net core.
I wrote this in Startup>Configure
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404)
{
var page = HttpFailedTemplates.NotFoundPage(context.Request.Path,
context.TraceIdentifier,
DateTime.Now.ToString(),
"نیل سافت",
"https://localhost:44313/");
// in page I have -> <script src='https://localhost:44347/js/libraries/jquery.min.js'></script> in <body> tag
context.Response.ContentType = "text/html";
var buffer = Encoding.UTF8.GetBytes(page);
using (var stream = context.Response.Body)
{
await stream.WriteAsync(buffer, 0, buffer.Length);
await stream.FlushAsync();
}
await next();
}
});
But after return response I don't have Script tags
I Added my Script tag in Head tag. Now it work.