简体   繁体   中英

Automate verifying website in IIS

As a part of build output for a ASP.NET website project we create a bin folder. In order to validate that the build output is actually a functional website we load it into the IIS. And, the browse to it.

Is there a way to automate this in C# ?

I am not looking for a test framework to do this. Just a simple C# light-weight application that can point IIS to this bin folder, test the web application loads thats all.

Make your IIS VirtualDirectory/Application point to your bin folder, or a drop folder that you copy all the bin folders content when you do a Build.

Then do an IISReset:

System.Diagnostics.Process.Start("C:\Windows\System32\iisreset.exe");

Then hit the website using a Webclient:

WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); 
Stream data = client.OpenRead (webUrl);
StreamReader reader = new StreamReader (data); 
string s = reader.ReadToEnd (); 
Console.WriteLine (s); 
data.Close (); 
reader.Close ();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM