我一直在尝试解决服务器上使用的安全性工具报告的XSS相关问题。它是“ / Logon / Index”页面上“ ReturnUrl”参数的跨站点脚本。我浏览了StackOverflow上几乎所有可用的帖子。我只是不知道如何解决此路由问题。任何指导将不胜感激。
我使用了AntiXssEncoder库。
<httpRuntime encoderType="System.Web.Security.AntiXss.AntiXssEncoder,System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
在“ Logon \ Index”方法中,我已经编码了url参数。我使用下面的代码重定向用户。
string encodedurl = HttpUtility.UrlEncode(returnUrl, Encoding.UTF8);
Response.Redirect(encodedurl);
我的url参数是:“ ReturnUrl = / fly / Manage”
https://localhost:7777/fly/Logon/Index?ReturnUrl=/fly/Manage
实际:https://localhost:7777/fly/Logon/%2Ffly%2FManage
所需:https://localhost:7777/%2Ffly%2FManage
如果我不使用HttpUtility.UrlEncode,请改用 Response.Redirect(returnUrl);使用“ ReturnUrl = / fly / Manage”
浏览器会自动将用户重定向到所需的网址:https://localhost:7777/fly/Manage
我是Windows开发人员,对asp.net或mvc路由没有太多的经验。任何帮助将不胜感激。谢谢。