Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 输入URL-likehttp://example.com 操作输入中对http:/example.com的更改_C#_Asp.net Mvc_C# 4.0_Asp.net Mvc Routing_Asp.net Mvc 4 - Fatal编程技术网

C# 输入URL-likehttp://example.com 操作输入中对http:/example.com的更改

C# 输入URL-likehttp://example.com 操作输入中对http:/example.com的更改,c#,asp.net-mvc,c#-4.0,asp.net-mvc-routing,asp.net-mvc-4,C#,Asp.net Mvc,C# 4.0,Asp.net Mvc Routing,Asp.net Mvc 4,我问了一个问题以获取URL作为操作输入。现在我有一个新问题。传递给操作的URL从更改为http://example.com 到http://example.com 我想知道为什么以及如何解决这个问题 附言:我添加此代码是为了解决问题,但我认为将来可能还会有其他问题!代码是: if ((url.Contains(":/")) && !(url.Contains("://"))) { url = url.Replace(":/", "://"); } 使用正则表达式: st

我问了一个问题以获取URL作为操作输入。现在我有一个新问题。传递给操作的URL从更改为http://example.com 到http://example.com

我想知道为什么以及如何解决这个问题

附言:我添加此代码是为了解决问题,但我认为将来可能还会有其他问题!代码是:

if ((url.Contains(":/")) && !(url.Contains("://")))
{
    url = url.Replace(":/", "://");
}
使用正则表达式:

string src = @"http://example.com";
string result = Regex.Replace(src, @"(?<=https?:/)/", "");
如果需要恢复,请执行以下操作:

string src = @"http:/example.com";
string result = Regex.Replace(src, @"(?<=https?:)/(?=[^/])", @"//");
使用正则表达式:

string src = @"http://example.com";
string result = Regex.Replace(src, @"(?<=https?:/)/", "");
如果需要恢复,请执行以下操作:

string src = @"http:/example.com";
string result = Regex.Replace(src, @"(?<=https?:)/(?=[^/])", @"//");

浏览器或服务器正在将双斜杠替换为单斜杠。 试试看

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


如果您可能获得安全的URL,请将其添加到路由/http/example.com或/https/example.com

浏览器或服务器正在将双斜杠替换为单斜杠。 试试看

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


如果您可能获得安全的URL,请将其添加到路径/http/example.com或/https/example.com

中,在一个不相关的便笺上,您的代码似乎正在将所有凹陷/未确定的面替换为倾斜的惊恐面。在一个不相关的便笺上,看起来您的代码正在用倾斜的恐惧面孔替换所有凹陷/未确定的面孔。您知道为什么会发生这种情况吗?是的,我的代码替换href在任何字符串中正确地斜杠,如果字符串为http://google.com http://google.com谢谢。我会用你的方式,但我想知道为什么。抱歉,没有将您的答案设置为已接受!你们知道为什么会这样吗?是的,我的代码替换href在任何字符串中正确地斜杠,若字符串是这样,你们的代码就错了http://google.com http://google.com谢谢。我会用你的方式,但我想知道为什么。抱歉,没有将您的答案设置为已接受!