问题描述
我正在开发一个asp.net mvc核心应用程序,并试图允许两次转义.
I am working on a asp.net mvc core application and trying to allow double escaping.
我的编辑" URL的电话号码为超链接(例如:+123).我知道如何使用普通的asp.net mvc应用程序.我曾经将web.config文件更改为
My Edit url has a phone number as hyperlink (Ex: +123). I know how to do with a normal asp.net mvc application. I used to change web.config file as
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true"/>
</security>
</system.webServer>
但是我现在在没有web.config的Asp.Net MVC Core应用程序上.我该如何以及在何处进行管理?
But I am right now on Asp.Net MVC Core application with out a web.config. How and where can I manage this?
推荐答案
ASP.NET Core应用程序可以托管在各种Web服务器(IIS,Kestrel,Nginx,Apache等)上.所有这些Web服务器都不了解请求过滤(特别是启用双重转义),这是IIS的本机功能.这是一个托管问题,ASP.NET Core应用程序不应直接处理它.如果像http://youserver.com/Home/Phone/+12345
这样的URL将到达ASP.NET Core管道,则将不以任何特殊方式处理加号,并且会将字符串模型视为+
字符.
ASP.NET Core application could be hosted on variety of web servers (IIS, Kestrel, Nginx, Apache, ...). All these web servers know nothing about request filtering (and particularly enabling of double escape) which is a native IIS feature. It's a hosting concern and ASP.NET Core application should not deal with it directly. If URL like http://youserver.com/Home/Phone/+12345
will reach ASP.NET Core pipeline, plus sign will not be treated in any special way and will get to string model as +
character.
当您在IIS上托管应用程序时,web.config仍在使用中,因此您可以像通常的ASP.NET应用程序一样配置<requestFiltering allowDoubleEscaping="true"/>
.同样,您不必担心会以非ASP.NET Core方式进行操作.您配置托管问题;这不是ASP.NET Core的领域.
When you host your application on IIS, web.config is still in use, so you could configure <requestFiltering allowDoubleEscaping="true"/>
as for usual ASP.NET application. Again, you should not be afraid that you do something in non ASP.NET Core way. You configure a hosting concern; it's not the field of ASP.NET Core.
如果要在另一个Web服务器中托管应用程序,则应检查其如何处理特殊字符.我知道Kestrel只会照原样传递此类URL,因此,如果托管在Kestrel上,则无需执行任何特定操作.
If you want to host application in another Web server, you should check how it handle special characters. I know that Kestrel will just pass such URLs as is, so you don't need to take any specific actions if hosted on Kestrel.
这篇关于Asp.Net MVC Core支持双重转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!