如何从c#WinForms应用程序在Web浏览器中运行ASP.NET Web应用程序?

时间:2016-05-26 08:40:45

标签: c# iis

我开发了一个Win Forms应用程序,在目录中搜索ASP.NET文件

目录始终包含ASP.NET文件(.aspx等)

如何使用c#从Win Forms运行ASP.NET Web应用程序?

我发现代码如下,但我无法弄清楚如何附加ASPX文件夹。

//thread to start IIS
public static void Thread1()
{
    //thread for running IIS
    using (Process proc = new Process())
    {
        proc.StartInfo.FileName = @"C:\Program Files\IIS Express\iisexpress.exe";
        proc.StartInfo.Arguments = @"/path:""c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles"" /vpath:/asp.netwebadminfiles /port:61569 /clr:4.0 /ntlm";
        //proc.StartInfo.CreateNoWindow = true;
        proc.StartInfo.UseShellExecute = false;
        proc.StartInfo.RedirectStandardOutput = true;
        proc.Start();
        proc.WaitForExit();
        //output from the process run
        Console.Out.WriteLine(proc.StandardOutput.ReadToEnd());
    }
}

public void OpenThread()
{
    Thread thread1 = new Thread(new ThreadStart(IISMngr.Thread1));
    thread1.Start();
    using (Process proc1 = new Process())
    {
        proc1.StartInfo.FileName = @"C:\Program Files\Internet Explorer\iexplore.exe";
        proc1.StartInfo.Arguments = @"http://localhost:61569/asp.netwebadminfiles/Default.aspx?applicationPhysicalPath=C:\FFF\AspProject\&applicationUrl=/";
        proc1.StartInfo.UseShellExecute = false;
        proc1.StartInfo.RedirectStandardOutput = true;
        proc1.StartInfo.CreateNoWindow = true;
        proc1.Start();
        proc1.WaitForExit();
        //output from the process run
        Console.Out.WriteLine(proc1.StandardOutput.ReadToEnd());
    }
}

"?applicationPhysicalPath = C:\ FFF \ AspProject \" 是ASP.NET Web App所在的位置(aspx等)

0 个答案:

没有答案