我问了一个问题来获取 URL 作为操作输入 here .现在我有一个新问题。传递给操作的 URL 从 http://example.com 更改为 http:/example.com。
我想知道为什么以及如何解决这个问题。
P.S: 我添加了这段代码来解决,但我认为将来可能会有其他问题!代码是:
if ((url.Contains(":/")) && !(url.Contains("://")))
{
url = url.Replace(":/", "://");
}
请您参考如下方法:
浏览器(或服务器)将双斜杠(非法)替换为单斜杠。
试试吧,
http://stackoverflow.com/questions/11853025//input-url-like-http-site-com-changes-to-http-site-com-in-action-input
(在 Chrome 中)转到:
http://stackoverflow.com/questions/11853025/input-url-like-http-site-com-changes-to-http-site-com-in-action-input
如果我是你,我会从你的路径中删除 http://并稍后添加它。
http://localhost:1619/Utility/PR/example.com/
然后,url = "http://"+ url;
如果您可能获得安全网址,请将其添加到路由 /http/example.com 或 /https/example.com
