我在asp.net-mvc-4
中开发了一个网站Visual Studio-2010
,该网站从位于其他位置的另一个SQL数据服务器获取数据。我使用端口443进行连接和用户登录以获取数据。网站在调试模式下工作正常,它从数据服务器中提取数据但是当我通过windows IIS
上传网站时,它不会与数据服务器建立任何连接,因此无法获取数据。它失败了
if (c.TryLogOn(AccountData.LogInUserName, AccountData.PW))
完整的方法是
try {
using (Client c = AccountData.c)
//using (TcpClient c = new TcpClient())
{
if (c.TryLogOn(AccountData.LogInUserName, AccountData.PW))
{
imc.Search.Base.Query.Query q = new imc.Search.Base.Query.Query();
AddAttributeListForFahrzeug(q);
AttributeValuesCollection values = c.FindInstances(q);
if (tempVehicleType == "all")
{
foreach (object[] av in values)
{
Fahrzeug d = NewFahrzeug(av);
d.VehicleType = tempVehicleType;
returnValue.Add(d);
}
}
else
{
foreach (object[] av in values)
{
Fahrzeug d = NewFahrzeug(av);
if (d.FzgBeschreibung == tempVehicleType)
{
d.VehicleType = tempVehicleType;
returnValue.Add(d);
}
//d.VehicleType = tempVehicleType;
}
}
c.LogOff();
}
}
} catch ( Exception ){
}
与客户的连接
static public AccountSettings GetAccountData()
{
AccountSettings AccountData = new AccountSettings();
System.Security.SecureString Pw = new System.Security.SecureString();
string PwWord = "**********";
string LogInUserName = "username";
foreach (char ch in PwWord)
{
Pw.AppendChar(ch);
}
//AccountData.c = new Client("abc.xyz.zhg.com", 443, true, ConnectionMode.Internet);
AccountData.c = new Client("abc.xyz.zhg.com", 1199, false, ConnectionMode.Remote);
AccountData.PW = Pw;
AccountData.LogInUserName = LogInUserName;
return (AccountData);
}
然后
AccountSettings AccountData = GetAccountData();