使用WPF C#从Intranet throw代理连接到Internet上的SQL Server [英] Connect to SQL Server on internet from intranet throw proxy using WPF C#

查看:104
本文介绍了使用WPF C#从Intranet throw代理连接到Internet上的SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在开发一个程序,它连接到SQL Server,我获得了静态/公共IP,请将其说成:141.52.88.212在2458端口。



该程序工作正常并连接到服务器,互联网上没有任何问题。



但是,我在我的公司PC中安装了只有内联网的程序。要连接到互联网我必须使用代理让它说:215.221.60.4在80端口(这不是真正的IP)。



现在的问题是由于代理设置明显,该程序无法运行。



如何在WPF应用程序中添加代理设置?



我使用以下连接字符串:



Hello,

I am developing a program which is connecting to SQL Server which I obtained a static/public IP for it let say it as: 141.52.88.212 on port 2458.

The program is working fine and connected to the server without any issue from everywhere in internet.

However, I installed the program inside my company PC which have intranet only. To connect to internet I have to use proxy let say it as: 215.221.60.4 on port 80 (this is not the real IP).

Now the problem is that the program is not working because of proxy setting obviously.

How can I add the proxy setting in my WPF application?

I am using the following connection string:

connectionString="Server=141.52.88.212\\SQLSERVER,2458;MultipleActiveResultSets=True;Async=true;User ID=UserTest;Encrypt=FALSE;TrustServerCertificate=FALSE;initial catalog=SQLT_TEST;Application Name=SSMA for Access;Pooling=False;PASSWORD=Pass;"





此连接正常没有在公司内部的任何计算机上罚款。



我试图插入代理设置如下:



在App.config中:



This connection is working fine on any computer not inside the company.

I tried to insert proxy setting as below:

in App.config:

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true"/>
  </system.net>





在App.xaml中.cs:



In App.xaml.cs:

private void Application_Startup(object sender, StartupEventArgs e)
{
IWebProxy webProxy = new WebProxy("215.221.60.4", 80);
webProxy.Credentials = CredentialCache.DefaultCredentials;
WebRequest.DefaultWebProxy = webProxy;
}





但没有运气。



请帮忙我。



谢谢。



更新:



我与IT讨论并且他们说代理处理所有协议。



然而,我试图将我的端口更改为(80)因为之前的端口被防火墙拒绝了,现在的问题是,当我们使用Wireshark程序检查时,我的程序试图直接连接到服务器而不去抛出代理。



是有没有办法检查我的sqlconnection是否在WPF中正确设置了代理设置?



此外,有没有办法将SQL协议更改为HTTP而不是使用任何TCP其他方式,例如HTTP-Tunneling?



But no luck.

Please help me.

Thanks.

UPDATE:

I discussed with IT and they said that the proxy deals with all protocols.

However, I tried to change my Port to (80) because the previous port was rejected by firewall and now the problem is that when we check using Wireshark program, my program is trying to connect to the server directly without going throw Proxy.

Is there a way to check if my sqlconnection is actually having proxy setting correctly in WPF?

Also, is there a way to change SQL protocol to HTTP rather than TCP using any other way such as HTTP-Tunneling for example?

推荐答案

sql server通信协议不是http。



您公司的内部代理可能只处理http协议,因此无法通过http代理连接到外部sql服务器。



与系统管理员联系,询问是否可以在防火墙中创建例外以便与外界建立连接。





JAFC
The sql server communication protocol is not http.

Probably the internal proxy of your company only deals with http protocol, so it is not possible to connect to an external sql server via http proxy.

Talk to your system administrator, and ask if it is possible to create an exception in the firewall in order to make a connection to the outside.


JAFC


这篇关于使用WPF C#从Intranet throw代理连接到Internet上的SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆