-3
我有URL需要用另一个网址替换部分网址。用c#中的另一个URL替换部分网址?
原始URL http://oldurl/dept/it/Lists/Contract Management System/DispForm.aspx?ID=4
我想只更换http://oldurl
(只)有http://www.newurl.com
。其余的网址会动态变化。
我有URL需要用另一个网址替换部分网址。用c#中的另一个URL替换部分网址?
原始URL http://oldurl/dept/it/Lists/Contract Management System/DispForm.aspx?ID=4
我想只更换http://oldurl
(只)有http://www.newurl.com
。其余的网址会动态变化。
Request.oldURL.GetLeftPart(UriPartial.Authority)
将返回自己的基本网址字符串,它是http://oldurl
string oldURL = "http://oldurl/bs/blabla";
string newURL = oldURL.Replace(Request.oldURL.GetLeftPart(UriPartial.Authority), "http://www.newurl.com");
查看更多:https://msdn.microsoft.com/en-us/library/system.uri.getleftpart(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/fk49wtc1(v=vs。 110).aspx –
为什么这需要一个正则表达式? – d0nut
因为... http:// sp2013qa会改变每个环境。 – James123