HttpWebRequest possibly slowing website

Posted by Steven Smith on Stack Overflow See other posts from Stack Overflow or by Steven Smith
Published on 2014-08-22T08:31:31Z Indexed on 2014/08/22 10:20 UTC
Read the original article Hit count: 194

Using Visual studio 2012, C#.net 4.5 , SQL Server 2008, Feefo, Nopcommerce

Hey guys I have Recently implemented a new review service into a current site we have.

When the change went live the first day all worked fine.

Since then though the sending of sales to Feefo hasnt been working, There are no logs either of anything going wrong.

In the OrderProcessingService.cs in Nop Commerce's Service, i call a HttpWebrequest when an order has been confirmed as completed. Here is the code.

var email = HttpUtility.UrlEncode(order.Customer.Email.ToString());
var name = HttpUtility.UrlEncode(order.Customer.GetFullName().ToString());
var description = HttpUtility.UrlEncode(productVariant.ProductVariant.Product.MetaDescription != null ? productVariant.ProductVariant.Product.MetaDescription.ToString() : "product");
var orderRef = HttpUtility.UrlEncode(order.Id.ToString());
var productLink = HttpUtility.UrlEncode(string.Format("myurl/p/{0}/{1}", productVariant.ProductVariant.ProductId, productVariant.ProductVariant.Name.Replace(" ", "-")));

string itemRef = "";

try
{
    itemRef = HttpUtility.UrlEncode(productVariant.ProductVariant.ProductId.ToString());
}
catch
{
    itemRef = "0";
} 

var url = string.Format("feefo Url",
login, password,email,name,description,orderRef,productLink,itemRef);

var request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = false;
request.Timeout = 5000;
request.Proxy = null;

using (var response = (HttpWebResponse)request.GetResponse())
{
    if (response.StatusDescription == "OK")
    {
        var stream = response.GetResponseStream();
        if(stream != null)
        {
            using (var reader = new StreamReader(stream))
            {
                var content = reader.ReadToEnd();
            }
        }
    }
}

So as you can see its a simple webrequest that is processed on an order, and all product variants are sent to feefo.

Now:

  1. this hasnt been happening all week since the 15th (day of the implementation)
  2. the site has been grinding to a halt recently.

The stream and reader in the the var content is there for debugging.

Im wondering does the code redflag anything to you that could relate to the process of website? Also note i have run some SQL statements to see if there is any deadlocks or large escalations, so far seems fine, Logs have also been fine just the usual logging of Bots.

Any help would be much appreciated!

EDIT: also note that this code is in a method that is called and wrapped in A try catch

UPDATE: well forget about the "not sending", thats because i was just told my code was rolled back last week

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server-2008