来自c#代码的网络访问(从ASP.Net调用) [英] Network access from c# code (called from ASP.Net)

查看:60
本文介绍了来自c#代码的网络访问(从ASP.Net调用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello

我们有一个用ASP.Net编写的Web应用程序,它调用外部C#程序(.exe)。此C#程序需要从其他服务器访问数据,但无法执行此操作。我们在Web配置中使用impersonate,以便ASP代码能够访问网络并且工作正常。但是,由于从ASP代码调用了C#exe,它显然没有使用web代码中为ASP代码指定的userID的特权运行

我们尝试使用。来信任这个程序集。 Net Framework向导尽可能达到最高级别,但这并没有帮助。如果我们更改machine.config并在流程模型中对用户ID和密码进行硬编码。 (更改系统/自动生成),C#程序能够访问网络,但我不确定这是否是正确的方法..

我们使用System.Diagnostics调用exe .Process .Start(我们指定startinfo.filename作为执行C#exe的文件名


我们没有C#代码(只是exe),所以把不能选择将C#程序的功能放到ASP页面代码中


有人可以帮忙找出理想的方法吗?

谢谢

Hello
We have a web application written in ASP.Net that calls an external C# program (.exe). This C# program needs to access data from a different server and is not able to do so. We use impersonate in the web config for the ASP code to be able to access the network and it is working fine. But since the C# exe is being called from the ASP code, it is apparently not running with the privileges of the userID specified in the web.config for the ASP code
We tried trusting this assembly using the .Net Framework wizard to the highest level possible, but that didn''t help. If we change the machine.config and hardcode the userid and password in the "process model" (change the system/autogenerate), the C# program is able to access the network, but I am not sure that is the right way to do this..
We call the exe by using System.Diagnostics.Process .Start (we specify the startinfo.filename as the filename of the C# exe to execute

We don''t have the C# code (just the exe), so putting the functionality of the C# program into the ASP page code is not an option

Could someone please help figure out the ideal way to do this?
Thanks

推荐答案

" Joseph"< jo ********** @ nospam.com>写在消息中

news:B0 ********************************** @ microsof t.com ...
"Joseph" <jo**********@nospam.com> wrote in message
news:B0**********************************@microsof t.com...
您好,
我们有一个用ASP.Net编写的Web应用程序,它调用外部的
C#程序(.exe)。这个C#程序需要访问来自不同的数据

服务器并且无法这样做。我们在网络公司中使用模仿nfig for

ASP代码能够访问网络并且工作正常。但是,因为从ASP代码调用了C#exe,所以显然不是运行时使用web.config中指定的userID权限运行的

ASP代码。我们尝试使用.Net Framework向导将此程序集信任到
最高级别,但这并没有帮助。如果我们更改

machine.config并在流程模型中修改用户ID和密码

(更改系统/自动生成),C#程序就能够访问

网络,但我不确定这是否是正确的方法...我们使用System.Diagnostics.Process .Start调用exe(我们指定
startinfo .filename作为要执行的C#exe的文件名。
我们没有C#代码(只是exe),所以将
C#程序的功能放入ASP页面代码中一个选项。
有人可以帮忙找出理想的方法吗?
谢谢
Hello,
We have a web application written in ASP.Net that calls an external C# program (.exe). This C# program needs to access data from a different
server and is not able to do so. We use impersonate in the web config for
the ASP code to be able to access the network and it is working fine. But
since the C# exe is being called from the ASP code, it is apparently not
running with the privileges of the userID specified in the web.config for
the ASP code. We tried trusting this assembly using the .Net Framework wizard to the highest level possible, but that didn''t help. If we change the
machine.config and hardcode the userid and password in the "process model"
(change the system/autogenerate), the C# program is able to access the
network, but I am not sure that is the right way to do this... We call the exe by using System.Diagnostics.Process .Start (we specify the startinfo.filename as the filename of the C# exe to execute)
We don''t have the C# code (just the exe), so putting the functionality of the C# program into the ASP page code is not an option.
Could someone please help figure out the ideal way to do this?
Thanks




我会推荐这篇文章朋友已经发给我了。
http://www.15秒。 com / Issue / 020312.htm



I''d recommend this article that a friend had sent to me.
http://www.15seconds.com/Issue/020312.htm


感谢您的快速回复...我可以通过修改来使应用程序正常工作Ť他在machine.config中处理模型用户ID /密码。我对此方法唯一关注的是,我在此服务器上安装的任何其他.Net Web应用程序将自动获得此用户ID所具有的权限,这不是所希望的。有没有办法让我只能将这些权利赋予我在我的代码中调用的C#程序(而不是以后可能安装的任何其他应用程序)


谢谢
Thank you for your quick response... I am able to get the application to work by modifying the proceess model user ID/password in the machine.config. The only concern I have with this approach is that any other .Net web application that I install on this server will automatically get the rights that this user ID has and that is not something desirable. Is there a way that I can give these rights only the C# program that I am calling in my code (and not to any other application that might be installed at a later point in time)

Thanks


" Joseph" <乔********** @ nospam.com>在消息中写道

news:6E ********************************** @ microsof t.com ...
"Joseph" <jo**********@nospam.com> wrote in message
news:6E**********************************@microsof t.com...
感谢您的快速回复......我可以通过修改machine.config中的过程模型用户ID /密码来获得
工作的应用程序。

我对这种方法的唯一顾虑是我在这台服务器上安装的任何其他.Net web

应用程序将自动获得权利
$ b这个用户ID具有的$ b,这是不可取的。有没有办法

我只能在我的

代码中调用C#程序这些权限(而不是任何可能安装在其中的任何其他应用程序)以后

时间点)?
谢谢
Thank you for your quick response... I am able to get the application to work by modifying the proceess model user ID/password in the machine.config.
The only concern I have with this approach is that any other .Net web
application that I install on this server will automatically get the rights
that this user ID has and that is not something desirable. Is there a way
that I can give these rights only the C# program that I am calling in my
code (and not to any other application that might be installed at a later
point in time)?
Thanks




这可能就是你要找的东西,搜索VS.NET 冒充

和还原的文档。在UNIX上,它似乎与su命令

类似(在功能上)。



This might be what you''re looking for, search VS.NET docs for "Impersonating
and Reverting". It appears to work similarly (in function) to the su command
on UNIX.


这篇关于来自c#代码的网络访问(从ASP.Net调用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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