开发者

ASP.NET Why is this shortening url code redirecting to page

Hey I have the following method

public static string GetShortenedURL(String inURL)
{
    String shortURL = "";
    String queryURL = "http://api.bit.ly/shorten?version=2.0.1&longUrl=" + inURL + "&login=&apiKey=";

    HttpWebRequest request = WebRequest.Create(queryURL) as HttpWebRequest;

    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string jsonResults = reader.ReadToEnd();
        int indexOfBefore = jsonResults.IndexOf("shortUrl\": \"") + 12;
        int indexOfAfter = jsonResults.IndexOf("\"", indexOfBefore);
        shortURL = jsonResults.Substring(indexOfBefore, indexOfAfter - indexOfBefore);

    }

    return shortURL;
}

Which worked fine on my development machine, but on live server for some reason whenever I call this method I actually seems to visit the URL aswell. The reason why this is a problem is because that URL updates a status of a recor开发者_开发技巧d. But I only want to do this when the user clicks on the link in the mail but for some very weird reason when Im creating the email on my confirmation page of registration and call this shortened URL method so I can add the short URL in my mail to send out, it seems to visit it by itself. Hence updating my status when it shouldnt yet.

Any Ideas ?

EDIT : This is how i call it

emailBody.Append(M1Utils.GetShortenedURL(ConfigurationSettings.AppSettings["strSite_FEURL"].ToString() + "login/verify.aspx?" + strEncrypted)).Append("\r\n\r\n");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜