在.NET应用程序中使用tinyurl.com ......可能吗? [英] Using tinyurl.com in a .Net application ... possible?

查看:196
本文介绍了在.NET应用程序中使用tinyurl.com ......可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现下面的code创建一个tinyurl.com网址:

I found the following code to create a tinyurl.com url:

http://tinyurl.com/api-create.php?url=http://myurl.com

这将自动创建一个TinyURL的URL。有没有办法做到这一点使用code,特别是C#在ASP.NET?

This will automatically create a tinyurl url. Is there a way to do this using code, specifically C# in ASP.NET?

推荐答案

您也许应该增加一些错误检查等,但是这可能是做的最简单的方法:

You should probably add some error checking, etc, but this is probably the easiest way to do it:

System.Uri address = new System.Uri("http://tinyurl.com/api-create.php?url=" + YOUR ADDRESS GOES HERE);
System.Net.WebClient client = new System.Net.WebClient();
string tinyUrl = client.DownloadString(address);
Console.WriteLine(tinyUrl);

这篇关于在.NET应用程序中使用tinyurl.com ......可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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