This nuget package will help you to shorten your long url into shortest on by using Bitly rest api service.
$ dotnet add package KiwiSoft.Bitly{
"KiwiSoft.Bitly": {
"GroupGuidId": "GKcgnMiNain",
"Token": "563e96dfffd3d5e744dca8172719b01aed23eb09"
}
}
And on the C# code, you just need to call new Shortener() to create a new instant.
Shortener shortener = new Shortener();
ReturnURL result = await shortener.CreateAsync("https://edi.wang/post/2019/4/24/how-to-pack-a-net-core-class-library-and-upload-to-nuget");
string url = result.Status?result.Url:string.Empty;
Configuration configuration = new Configuration();
configuration.GroupGuid = "GKcgnMiNain";
configuration.Token = "563e96dfffd3d5e744dca8172719b01aed23eb09";
Shortener shortener = new Shortener(configuration);
ReturnURL result = await shortener.CreateAsync("https://edi.wang/post/2019/4/24/how-to-pack-a-net-core-class-library-and-upload-to-nuget");
string url = result.Status?result.Url:string.Empty;
You can find out whether the operation is successful or not by looking at the value of Status property on ReturnUrl. And the shortened url can be retrieved from Url property.