Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi

I am using rest API it working fine on local Machine

but when I host on IIS it not working..

Unable to connect to the remote server


at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.QueryResult.Execute()
at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
at System.Data.Services.Client.DataServiceQuery`1.Execute()
at System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MaacoTotals._Default.LoadSeetings()

in D:\MaacoTotals\MaacoTotals\MaacoTotals\MaacoTotals\Default.aspx.cs:line
Posted
Comments
[no name] 1-Nov-13 1:32am    
Can you add your code part which generates error and few more details.
Ganesh_verma 6-Nov-13 1:11am    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using MaacoTotals.BAL;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using MaacoTotals.DAL;
using MaacoTotals.Opportunity;
using System.Globalization;
using System.Data.Services.Client;
using Mitchell.Repair.Services.Partner.Core;
using System.Net;
using System.Threading;

namespace MaacoTotals
{
public partial class _Default : System.Web.UI.Page {





private void LoadSeetings()
{
try
{
//Here we get the error in the below line 1 when we host on iis 7 it working on same machine using Code sample.
//but when we publish and host6 on iis 7 on same machine its not working on same machine..

//line 1
this.Myopp = new OpportunityEntities(new Uri(string.Format(CultureInfo.CurrentCulture, "{0}{1}Opportunity/OpportunityService.svc/Opportunities(Id=" + OpportunityDetails.opportunity_id + ",ShopId='" + OpportunityDetails.shop_id + "')", ConfigurationManager.AppSettings["BaseApiUrl"].Trim(), (ConfigurationManager.AppSettings["BaseApiUrl"].Trim().EndsWith("/")) ? string.Empty : "/")));

//line 2

this.Myopp.SendingRequest += this.Context_SendingRequest;

//line 3

this.Myopp.IgnoreResourceNotFoundException = true;



}
catch (Exception ex)
{
RequestData.WriteMyLog(ex.Message + "Message 1 " + ex.StackTrace.ToString() + "Message 2");

}


var Parts = (from
v in this.Myopp.Parts
where
v.Id != null
select
v
).ToList();

var Lines = (from
v in this.Myopp.Lines
where
v.Id != null
select
v
).ToList();

var Estimate = (Lines.AsEnumerable().Sum(x => x.EstimateAmount));
var LaborAmount = (Lines.AsEnumerable().Sum(x => x.LaborAmount));
OpportunityDetails.parts_Orginal = Convert.ToString(Estimate);
OpportunityDetails.labor_Orginal = Convert.ToString(LaborAmount);
BindDataParts();
BindDataLabors();



var content = from l in Lines
join p in Parts on l.Id equals p.Id
select new Lines
{
Parts_Qty = Convert.ToString(p.Qty),
Parts_Type = Convert.ToString(p.Type),
Parts_Description = Convert.ToString(l.Description),
Parts_PartNumber = Convert.ToString(p.PartNumber),
Parts_Estimate = Convert.ToString(l.EstimateAmount),
Lines_OpportunityId = Convert.ToString(l.OpportunityId),
Lines_ShopId = l.ShopId,
Parts_Id = p.Id,
Lines_Id = l.Id,
Lines_LaborAmount = l.LaborAmount,
Lines_Hours = l.Hours,
Lines_EstimateAmount = l.EstimateAmount

};
OpportunityDetails.MyLines = content.ToList();
gvMT.DataSource = content.ToList();
gvMT.DataBind();


//gvMT.DataSource = GetLinesList();
//gvMT.DataBind();


1 solution

Hi,

What serviec are you using any custom service of yours or Twitter service like general open source service.

Check the valid permissions are provided in IIS for accessing the remote server.

Check for Firewall Port block and any Config entries mismatch.

Debug and check exactly at which state error is thrown, at the request Time or when creating object for API itself.

Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900