I want to start IIS Express from within C# (to run UI Tests)
I have an MVC website that lives in "D:\GitHub\myProj\net5.Proj.Ui" - if I debug it within Visual Studio, the website runs perfectly well. Now I want to do some UI testing with selenium
My code starts IIS Express
var applicationPath = @"D:\GitHub\myProj\net5.Proj.Ui\bin\Debug\net6.0\";
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var _iisProcess = new Process();
_iisProcess.StartInfo.FileName = programFiles + @"\IIS Express\iisexpress.exe";
_iisProcess.StartInfo.Arguments = $"/path:{ applicationPath} /port:5000";
_iisProcess.EnableRaisingEvents = true;
_iisProcess.Start();
_iisProcess.WaitForExit();
The output gives me
Copied template config file 'C:\Program Files\IIS Express\AppServer\applicationhost.config' to 'C:\Users\Dave\AppData\Local\Temp\iisexpress\applicationhost2022715206710.config'
Updated configuration file 'C:\Users\Dave\AppData\Local\Temp\iisexpress\applicationhost2022715206710.config' with given cmd line info.
Starting IIS Express ...
Successfully registered URL "http://localhost:5000/" for site "Development Web Site" application "/"
Registration completed
IIS Express is running.
Enter 'Q' to stop IIS Express
Request started: "GET" http://localhost:5000/
Response sent: http://localhost:5000/ with HTTP status 403.14
When I open the browser, and nagivate to http://localhost:5000/ I get a 403 error, and I'm sure why