I need to start IIS Express via C # with WPF. I can even upload the site and browse, but for only a few seconds. Soon the site stops responding to requests, and only returns to respond when I close the application.
private void WinPrincipal_Loaded(object sender, RoutedEventArgs e)
{
IniciarSite();
}
public void IniciarSite()
{
string path = @"C:\Program Files\IIS Express\iisexpress.exe";
string argumentos = @"/path:C:\Sites /port:9090 /systray:true";
if (!File.Exists(path))
throw new FileNotFoundException();
var process = Process.Start(new ProcessStartInfo()
{
FileName = path,
Arguments = argumentos,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
});
}
Initially I thought it was because I was using some non-common ports like 9092, 8082. So I started testing with 9090, but it also happens, stops responding and only comes back when I close the application.
I also noticed that when I compile in "debug" the problem happens, however when compiling in "release" it works normally.