![](/img/trans.png)
[英]How can I execute an url call from C# code on a ASP website on a ASCX page?
[英]How can i execute C# code in Asp .Net Website
我是 C# .NET 的新手。 我想知道如何在 .aspx 网站 buttonClick 中执行 .cs 程序。
假设我想在按钮单击中执行以下代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 20;
int c = a + b;
Console.WriteLine(c);
Console.ReadKey();
}
}
}
和按钮点击 -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
Microsoft 不建议从 Web 应用程序调用 .exe,因为 w3wp.exe 出于安全原因在沙盒环境中运行,因此它启动的任何线程/任务/进程都与您自己启动时不同,因此可能无法按预期工作。
是可能的,但不推荐。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.