private static void SendResponse(string redirectToUrl, string queryString, ResponseStatus responseStatusCode, HttpRequestArgs args)
 {
     args.Context.Response.Status = responseStatusCode.Status;
     args.Context.Response.StatusCode = responseStatusCode.StatusCode;
     args.Context.Response.AddHeader("Location", redirectToUrl + queryString);
     args.Context.Response.End();
 }
        private static ResponseStatus GetResponseStatus(Item redirectItem)
        {
            var result = new ResponseStatus
            {
                Status = "301 Moved Permanently",
                StatusCode = 301,
            };

            if (redirectItem != null)
            {
                var responseStatusCodeId = redirectItem.Fields[Constants.Fields.ResponseStatusCode];

                if (responseStatusCodeId.HasValue && !string.IsNullOrEmpty(responseStatusCodeId.ToString()))
                {
                    var responseStatusCodeItem = redirectItem.Database.GetItem(ID.Parse(responseStatusCodeId));

                    if (responseStatusCodeItem != null)
                    {
                        result.Status = responseStatusCodeItem.Name;
                        result.StatusCode = responseStatusCodeItem.GetIntegerFieldValue(Constants.Fields.StatusCode, result.StatusCode);
                    }
                }
            }

            return result;
        }
 /// <summary>
 ///  Once a match is found and we have a Sitecore Item, we can send the 301 response.
 /// </summary>
 private static void SendResponse(Item redirectToItem, string queryString, ResponseStatus responseStatus, HttpRequestArgs args)
 {
     var redirectToUrl = GetRedirectToUrl(redirectToItem);
     SendResponse(redirectToUrl, queryString, responseStatus, args);
 }
        private static void SendResponse(string redirectToUrl, string queryString, ResponseStatus responseStatusCode, HttpRequestArgs args)
        {
	        string location = redirectToUrl + queryString;
	        string redirectMessage = string.Format("Redirect: [ Url: {0}; Status: {1} ]", location,
		        responseStatusCode.Status);
			Log.Info(redirectMessage, typeof(Redirects));
            args.Context.Response.Status = responseStatusCode.Status;
            args.Context.Response.StatusCode = responseStatusCode.StatusCode;
            args.Context.Response.AddHeader("Location", location);
            args.Context.Response.End();
        }