Asp.Net MVC Core enabling double escape

一个人想着一个人 提交于 2020-01-24 03:25:30

问题


I am working on a asp.net mvc core application and trying to allow double escaping.

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>

But I am right now on Asp.Net MVC Core application with out a web.config. How and where can I manage this?


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/49664759/asp-net-mvc-core-enabling-double-escape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!