gpt4 book ai didi

c# - 如何为 404 页面设置 UTF8

转载 作者:太空狗 更新时间:2023-10-30 01:32:08 25 4
gpt4 key购买 nike

我正在使用标准方法呈现 404 错误页面:

HttpContext.Response.ContentEncoding = Encoding.UTF8;
return HttpNotFound($"Запись идентификатором {id} и типом {type} не найдена");

但我编码错误: enter image description here

HttpNotFound方法不包含任何与编码相关的属性。如何将编码设置为 UTF-8回应?

我也尝试放置 <globalization requestEncoding="utf-8" responseEncoding="utf-8" />在 web.config 中,但它不起作用。

嗅探器的输出:

HTTP/1.1 404 ?????? ? ?????????????? 'f7c08f77-ffd9-4f85-bca6-6f4d04eba3ff' ? ????? '???????? ?????' ?? ???????         
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcQWxleFxEb2N1bWVudHNcdGVtcGxhdGVzXDFcRjdDMDhGNzctRkZEOS00Rjg1LUJDQTYtNkY0RDA0RUJBM0ZG?=
X-Powered-By: ASP.NET
Date: Wed, 06 Jul 2016 18:48:43 GMT
Content-Length: 6103

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IIS 10.0 Detailed Error - 404.0 - Çàïèñü ñ èäåíòèôèêàòîðîì 'f7c08f77-ffd9-4f85-bca6-6f4d04eba3ff' è òèïîì 'Ïå÷àòíàÿ ôîðìà' íå íàéäåíà</title>
<style type="text/css">
...

十六进制:

byte[] arrOutput = { 0x48, 0x54, 0x54, 0x50, 0x2F, 0x31, 0x2E, 0x31, 0x20, 0x34, 0x30, 0x34, 0x20, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xEF, 0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BF, 0xBD, 0xEF, 0xBF, 0xBD, 0x0D, 0x0A, 0x43, 0x61, 0x63, 0x68, 0x65, 0x2D, 0x43, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x3A, 0x20, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2F, 0x68, 0x74, 0x6D, 0x6C, 0x3B, 0x20, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3D, 0x75, 0x74, 0x66, 0x2D, 0x38, 0x0D, 0x0A, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3A, 0x20, 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x2D, 0x49, 0x49, 0x53, 0x2F, 0x31, 0x30, 0x2E, 0x30, 0x0D, 0x0A, 0x58, 0x2D, 0x41, 0x73, 0x70, 0x4E, 0x65, 0x74, 0x4D, 0x76, 0x63, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x35, 0x2E, 0x32, 0x0D, 0x0A, 0x58, 0x2D, 0x41, 0x73, 0x70, 0x4E, 0x65, 0x74, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x34, 0x2E, 0x30, 0x2E, 0x33, 0x30, 0x33, 0x31, 0x39, 0x0D, 0x0A, 0x58, 0x2D, 0x53, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6C, 0x65, 0x73, 0x3A, 0x20, 0x3D, 0x3F, 0x55, 0x54, 0x46, 0x2D, 0x38, 0x3F, 0x42, 0x3F, 0x51, 0x7A, 0x70, 0x63, 0x56, 0x58, 0x4E, 0x6C, 0x63, 0x6E, 0x4E, 0x63, 0x51, 0x57, 0x78, 0x6C, 0x65, 0x46, 0x78, 0x45, 0x62, 0x32, 0x4E, 0x31, 0x62, 0x57, 0x56, 0x75, 0x64, 0x48, 0x4E, 0x63, 0x64, 0x47, 0x5A, 0x7A, 0x58, 0x46, 0x56, 0x44, 0x52, 0x6B, 0x74, 0x63, 0x64, 0x6E, 0x4E, 0x75, 0x58, 0x47, 0x52, 0x6C, 0x64, 0x6C, 0x78, 0x4D, 0x59, 0x57, 0x35, 0x70, 0x64, 0x43, 0x35, 0x56, 0x51, 0x30, 0x5A, 0x4C, 0x4C, 0x6C, 0x42, 0x76, 0x63, 0x6E, 0x52, 0x68, 0x62, 0x46, 0x78, 0x30, 0x5A, 0x57, 0x31, 0x77, 0x62, 0x47, 0x46, 0x30, 0x5A, 0x58, 0x4E, 0x63, 0x4D, 0x56, 0x78, 0x47, 0x4E, 0x30, 0x4D, 0x77, 0x4F, 0x45, 0x59, 0x33, 0x4E, 0x79, 0x31, 0x47, 0x52, 0x6B, 0x51, 0x35, 0x4C, 0x54, 0x52, 0x47, 0x4F, 0x44, 0x55, 0x74, 0x51, 0x6B, 0x4E, 0x42, 0x4E, 0x69, 0x30, 0x32, 0x52, 0x6A, 0x52, 0x45, 0x4D, 0x44, 0x52, 0x46, 0x51, 0x6B, 0x45, 0x7A, 0x52, 0x6B, 0x59, 0x3D, 0x3F, 0x3D, 0x0D, 0x0A, 0x58, 0x2D, 0x50, 0x6F, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2D, 0x42, 0x79, 0x3A, 0x20, 0x41, 0x53, 0x50, 0x2E, 0x4E, 0x45, 0x54, 0x0D, 0x0A, 0x44, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x57, 0x65, 0x64, 0x2C, 0x20, 0x30, 0x36, 0x20, 0x4A, 0x75, 0x6C, 0x20, 0x32, 0x30, 0x31, 0x36, 0x20, 0x31, 0x38, 0x3A, 0x34, 0x38, 0x3A, 0x34, 0x33, 0x20, 0x47, 0x4D, 0x54, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x4C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x3A, 0x20, 0x36, 0x31, 0x30, 0x33, 0x0D, 0x0A, 0x0D, 0x0A, 0x3C, 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x57, 0x33, 0x43, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x58, 0x48, 0x54, 0x4D, 0x4C, 0x20, 0x31, 0x2E, 0x30, 0x20, 0x53, 0x74, 0x72, 0x69, 0x63, 0x74, 0x2F, 0x2F, 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x33, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x54, 0x52, 0x2F, 0x78, 0x68, 0x74, 0x6D, 0x6C, 0x31, 0x2F, 0x44, 0x54, 0x44, 0x2F, 0x78, 0x68, 0x74, 0x6D, 0x6C, 0x31, 0x2D, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x2E, 0x64, 0x74, 0x64, 0x22, 0x3E, 0x20, 0x0A, 0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x33, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x31, 0x39, 0x39, 0x39, 0x2F, 0x78, 0x68, 0x74, 0x6D, 0x6C, 0x22, 0x3E, 0x20, 0x0A, 0x3C, 0x68, 0x65, 0x61, 0x64, 0x3E, 0x20, 0x0A, 0x3C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C3, 0xA5, 0xC3, 0xAD, 0xC3, 0xA0, 0x3C, 0x2F, 0x74, 0x69, 0x74, 0x6C, 0x65, 0x3E, 0x20, 0x0A };

最佳答案

如果您设计了自己的定制 Custom Error 404 Page , 那么您可以使用 <%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %> 定义用于页面的编码.至于更改默认的编码 HttpNotFound错误页面,如果我能找到/想出一些东西,我会编辑。

关于c# - 如何为 404 页面设置 UTF8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38229870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com