如何删除“https”来自我的嵌入式链接 [英] How do I remove "https" from my embedded link

查看:148
本文介绍了如何删除“https”来自我的嵌入式链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要从嵌入式链接中删除 https



目前链接创建如下:< br $>


 https://tyrescanner.net/pages/Activation.aspx 





哪个不起作用我需要链接如下:



 tyrescanner.net/ pages / Activation.aspx 





我的代码到目前为止:

 < span class =code-keyword><   a     href     ='  + VirtualPathUtility.ToAbsolute(// tyrescanner.net/pages/Activation.aspx)+?ActivationCode =+ ActivationCode +' > 点击此处激活您的帐户。<   / a  > ; 

解决方案

您最好使用 System.Uri class。使用表示URI的字符串参数创建一个实例,该参数将字符串解析为URI组件,例如 Scheme Host ,依此类推:

https ://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx [ ^ ]。



要了解URI的组件,请参阅:

https://en.wikipedia.org / wiki / URI_scheme [ ^ ],
https://msdn.microsoft.com /en-us/library/system.uri%28v=vs.110%29.aspx [ ^ ]。



这是解析它的示例: https://en.wikipedia.org/wiki/URI_scheme#Examples [ ^ ]。



这样,您可以删除或替换某些片段,例如作为方案名称https,但如果你考虑如何避免使用表示数据的字符串而不是数据本身,那会更好。



-SA


将其替换为空字符串



  string  url =  < https://example.net/...>; 
string urlToUse = url.Replace( https:// ); // 空字符串





urlToUse 现在将拥有您要使用的URL。


 < span class =code-keyword><   a     href     ='  http :/+ VirtualPathUtility.ToAbsolute(// tyrescanner.net/pages/Activation.aspx)+?ActivationCode =+ ActivationCode +' > 点击此处激活您的帐户。<   / a  > ; 





但是ToAbsolute不应该包含域名,所以你应该ToAbsolute /pages/Activation.aspx然后在开始时添加http://域。

Hi folks, I need to remove https from my embedded link.

At the moment the link is created like this:

https://tyrescanner.net/pages/Activation.aspx



Which does not work I need the link to be like this:

tyrescanner.net/pages/Activation.aspx



My code so far:

<a href = '" + VirtualPathUtility.ToAbsolute("//tyrescanner.net/pages/Activation.aspx") + "?ActivationCode=" + ActivationCode + "'>Click here to activate your account.</a>";

解决方案

You should better use System.Uri class. Create an instance with string parameter representing your URI, which will parse the string into URI components, such as Scheme, Host, and so on:
https://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx[^].

For understanding the components of URI, please see:
https://en.wikipedia.org/wiki/URI_scheme[^],
https://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx[^].

This is the example of parsing it: https://en.wikipedia.org/wiki/URI_scheme#Examples[^].

This way, you can remove or replace some fragment, such as scheme name "https", but it would be much better if you think how to avoid using strings representing data instead of data itself.

—SA


Remove it by replacing it with an empty string,

string url = "<https://example.net/...>";
string urlToUse = url.Replace("https://", ""); // empty string



urlToUse would now have the URL that you want to use.


<a href = 'http:/" + VirtualPathUtility.ToAbsolute("//tyrescanner.net/pages/Activation.aspx") + "?ActivationCode=" + ActivationCode + "'>Click here to activate your account.</a>";



However ToAbsolute is not supposed to include a domain name, so you should ToAbsolute the "/pages/Activation.aspx" then add the http://domain at the start.


这篇关于如何删除“https”来自我的嵌入式链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆