IIS 不传递包含变音符号的 URL

发布于 2025-01-12 01:03:39 字数 1367 浏览 5 评论 0原文

我的 IIS 服务器上安装了 Django 应用程序。在我的本地 PC 上一切正常,但 IIS 应用程序上的链接/URL 如果包含变音符号则不起作用。如果我使用像“%”这样的符号,它就可以正常工作。

下面是附加文件链接的代码(我的本地和服务器都有相同的代码):

<p class="article-content mt-2 mb-1"><strong>Attachment: </strong><a href="{{post.file_close.url}}">{{post.file_close.name}}</a></p>

如果我上传文件 cars.png ,则两个版本中的一切都正常。无论扩展名、pdf、excel、图像等如何,这都有效。 问题是,如果我上传文件 carsčč.png 它仅在服务器端失败,在我的电脑上它工作得很好。 我在 Django/debugg 上收到以下错误:

Page not found (404)
“C:\inetpub\files\PyWeb\media\PN_files\2022\03\06\cars” does not exist

错误页面的 Url 是:

http://hidden_part/media/PN_files/2022/03/06/carsčč.png

但是当我单击复制并粘贴时,它是这样的:

http://hidden_part/media/PN_files/2022/03/06/cars%C4%8D%C4%8D.png

就像链接不完整一样,一旦遇到特殊字符,它就会停止。 但是,显示的链接仍然包含所有字母,它是 PN_files/2022/03/06/carsčč.png 尝试过: 我查看了区域设置,两台电脑上都是一样的。 另外,当我手动搜索该文件时,名称没有被破坏,它在本地保存为 carsčč.png。所以我猜这只是链接,尝试获取文件。 我发现这是因为变音字母。在我的“base.html”上,我有 meta charset="utf-8"。 Django 设置 LANGUAGE_CODE = 'hr-BA'

我使用 Bootstrap 4.0

服务器托管在 Windows、IIS、.NET 上,全球化设置设置为 utf-8。我需要在请求过滤中添加一些内容吗?

I have a Django app installed on my IIS server. Everything works great on my local PC but links/URL on IIS app don't work if the contain diacritic symbols. If I use symbols like '%' it works fine.

Below is the code for links to attached files (both my local and server have the same code):

<p class="article-content mt-2 mb-1"><strong>Attachment: </strong><a href="{{post.file_close.url}}">{{post.file_close.name}}</a></p>

If I upload file cars.png everything works fine in both versions. This works no matter the extension, pdf, excel, image, etc.
Problem is, if I upload file carsčč.png it fails only on server side, on my PC it works great.
I get the following error on my Django/debugg:

Page not found (404)
“C:\inetpub\files\PyWeb\media\PN_files\2022\03\06\cars” does not exist

Url of the error page is:

http://hidden_part/media/PN_files/2022/03/06/carsčč.png

But when I click copy and paste it's like this:

http://hidden_part/media/PN_files/2022/03/06/cars%C4%8D%C4%8D.png

Like the link is not complete, it stopped as soon as it runs into a special character.
But, shown link still containes all the letters, it's PN_files/2022/03/06/carsčč.png
Tried:
I looked at regional settings, it's the same on both PCs.
Also, when I manually search for the file, the name is not currupted, it's saved localy as carsčč.png. So I guess it's only the link, tring to get the file.
I figured out it's because of diacritic letters. On my 'base.html' I have meta charset="utf-8". Django setting LANGUAGE_CODE = 'hr-BA'.

I use Bootstrap 4.0 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">

Server is hosted on Windows, IIS, .NET Globalization settings are set to utf-8. Do I need to add something to Request filtering?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2025-01-19 01:03:39

我想你可以尝试在Request Filtering中设置配置,IIS服务器通过此配置将支持非ASCII字符,只需参考截图:
输入图片此处描述

I think you can try to set the configuration in Request Filtering, IIS server will supports non-ASCII characters via this configuration,just refer to the screenshot:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文