Giter VIP home page Giter VIP logo

automation-webhosting's Introduction

Automation : Web Hosting

This library is designed to allow the hosting of web applications (or sites) via a programatic interface. It utilizes IIS Express to spin up dedicated instances of your applications with support for both HTTP and HTTPS. We mainly developed this utility to aid in integration testing but it can certainly be used in other scenarios where web hosting is desired.

NuGet Version NuGet Download Count

Prerequisites

You will need IIS Express installed on your host machine. You can download it here or use the Web Platform Installer.

Quick Start

You can install this package via Nuget under the package id of RimDev.Automation.WebHosting.

PM> Install-Package RimDev.Automation.WebHosting

Once the package is installed, you can use the following code to start any web application.

var pathToWebsite = "C:\\mysite";
var siteName = "Contoso";

// async Task<IisExpress>
var instance = await IisExpress.CreateServer(pathToWebsite, siteName);

// sync
var instance = IisExpress.CreateServer(pathToWebsite, siteName).Result;

You can then access your site via the ports express in the IisExpress class instance. Those properties are described below.

Properties

Every IisExpress class instance has properties that make working with your new server instance easier.

  • AppConfigPath : The application host configuration where your site will be registered. This is where your bindings and site name are injected.
  • HttpPort : The HTTP port your application is listening on.
  • HttpsPort : The HTTPS port your application is listening on. To utilize the IIS Express development certificate HTTPS ports are required to be between 43300 and 43399.
  • ProcessId : The process in which your IIS Express instance is running in.

Constants / Members

The IisExpress class also has a two important members: DefaultIisExpressPath and DefaultAppConfigPath.

  • DefaultIisExpressPath : The assumed installation path for IisExpress.
  • defaultAppConfigPath : The assumed path to the applicationHost.config template used to construct your sites IIS Express configuration.

Start Up

When first initializing an IisExpress instance, a few steps are taken to insure you get a running web server.

  1. An available HTTP port is retrieved
  2. An available HTTPS port is retrieved
  3. The site unique applicationHost.config is created with the ports and site name, then written to disk.
  4. The IIS Express host process is started, and passed the config

Clean up

The IisExpress implementation implements the IDisposable interface. On Dispose, the process running your web application is stopped and the applicationHost.config file that was created is deleted.

Logging

All process logging is done using Trace. There are methods to access this via your favorite logging frameworks.

Thanks

Thanks to Ritter IM for supporting OSS.

automation-webhosting's People

Contributors

khalidabuhakmeh avatar jrusbatch avatar kendaleiv avatar

Watchers

Soundararajan Karunagaran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.