Category Archives: Deployment

Deploying Your Application to IIS on Your Dev Machine

A great way to test your LightSwitch application, or just learn how it works, is to publish it to IIS on your own machine. It is easy to do and once you have the kinks worked out, you can publish to a Web server with confidence.

This post is a continuation of the last article (here). It assumes your environment is configured and is ready to host a LightSwitch application.

Publishing Your Application

Just one wizard to go through…

  1. In LightSwitch, click Build>Publish to open the LightSwitch Publish Application Wizard.
  2. Chose the Web option and click Next.
    You will presented with three options. The IIS Server option is what we care about. Notice the IIS Server has the LightSwitch Deployment Perquisites installed checkbox. If this is your first time, clear that box. LightSwitch will install what it needs for you.
  3. The next window allows you to choose where the application will be deployed. You can create a package on disk or publish directly to a server. Since we are publishing on our own machine, we will publish directly to the server.
    Select Remotely publish to a server now.Enter the service URL. This is the URL to the site you will use. If it is the Default Web Site on your machine, it is simply http://YOUR MACHINE NAME.

    In the Site/Application field, you will specify the site you are using and name the application. You can name the application anything. LightSwitch will create it.

    Click Next.

  4. Here, you will configure the administrator and user connection strings.
    The administrator string is used when the administrator – likely you – uses the application. The user string is used when end-users run the application. If you see a yellow warning icon beside wither of the strings, that means you have something to fix. If there isn’t a warning icon, then the default strings are OK. The defaults for the administrator are typically OK, but you will probably have to specify or create a new user login. We will walk through them for good measure.Click the ellipses button next to the Specify administrator connection for new or existing database field.


    If you are using your own login credentials, then you don’t need to do anything. If you want to use a different login, then use this dialog to create it. Make sure the credentials you use have administrator privileges. You can also use the Test Connection button to make sure it works. Click OK when you are finished.

    The user connection will be used by everybody, so it is best to use a SQL server log in. If you don’t already have one, click the Create Database Login button to do so. Once you have a SQL Server, click the ellipses next to the Specify the user connection field.

    If you have just created a connection, it will be pre-populated. If you are using a different one, enter it.

    Test the connection and click OK and then click Next  in the publishing wizard to move to the next step.

  5.  The next screen allows you to specify a certificate. Since we are publishing this application for testing, we don’t need to worry about a certificate.Clear the Specify a certificate box and click Next.

(6)    Confirm your settings and click Publish.

Testing Your Application

Once your application is published, you are ready to take it for a spin. Assuming you published your application to the Default Web Site, access it by using this URL: http://YOUR_MACHINE_NAME/YOUR_APPLICATION_NAME (or the value you entered in the Site/Application field in the publishing wizard).

Configuring Windows 7 Machine to Host LightSwitch Web Applications

Most LightSwitch users want to deploy their Web applications to their own machine for testing and learning purposes. It is very easy to configure your machine to do so. In fact, you only need to do a few things. LightSwitch will do the rest. This post covers what you need to do to get your machine ready. My next post will cover the deployment process itself.

The instructions/examples are focused on Windows 7 and Internet Information Services (IIS) 7 and are intended for those who are in development, learning, or test mode. For full Web server configuration advice, check out Beth Massi’s post, “Deployment Guide: How to Configure a Web Server to Host LightSwitch Applications.”

These instructions assume you are using Windows 7 and have created your data entities in LightSwitch (intrinsic database). If your LightSwitch application uses external data, then ignore the bits on needing SQL server. In that case, you have already connected to a database.

What You Need

The basic components you will need to have installed are SQL Server (or SQL Server Express), Internet Information Services (IIS) 7, and .NET Framework 4.x.

  • If you don’t have SQL Server installed on your local machine, you can use any that you have access to. If you don’t have access to one, install SQL Server Express.
  • If you don’t have IIS installed, go to your control panel and enable it. (Very easy instructions)
  • Make sure you have .NET Framework 4.x. IF you don’t have it, get the latest here.

How Web Deployment Works

Publishing to the Web with LightSwitch is technically called 3-Tier Deployment. Your application is viewed in the browser on the client (Tier 1), it is hosted on IIS using LightSwitch application services (Tier 2), and uses data in the form of SQL Server or SQL Server Express (Tier 3).

Sound complicated? It’s not because we use LightSwitch. As long as you have the basics installed and configured (IIS, .NET Framework 4, and SQL Server or SQL Server Express), LightSwitch will do the rest.

Configuring Your Environment

There are just a couple things you need to do to make sure your environment is configured correctly: make sure your IIS application pool is using .NET 4.0, create a database, and set SQL Server to mixed authentication mode.

Setting up IIS

IIS hosts applications in application pools and each application pool has a property to specify which version of the .NET Framework to use. IIS’s Default Web Site is hosted by the DefaultAppPool and commonly uses .NET 2.0. Your LightSwitch application needs to use .NET 4.0 so you need to check the  .NET Framework version property and change it if necessary.

  1. Open the Computer Management console and expand the Services and Applications node.
  2. Select Internet Information Services Manager and the ISS page will open.
  3.  Expand the server node in the connections pane and select Application Pools. The list of application pools will open.
  4. Select DefaultAppPool, click Basic Settings, and set the .NET Framework version property to .NET Framework v4.x.
  5. Click OK to complete the change. You may also want to restart IIS for good measure.

That’s it. IIS is now ready!

Set up SQL Server

LightSwitch needs a database with mixed authentication to deploy correctly. Mixed authentication allows SQL or Windows authentication. You will see why when we get into the deployment process.

All you need to do is create a blank database and enable mixed authentication. I use SQL Server 2008 R2 and Microsoft SQL Server Management Studio, so these instructions use those applications.

Start by creating the database.

  1. Open your SQL Server management tool and connect to your server.
  2. Create a blank database by right-clicking on the Databases node and selecting New Database (the New Database window will open)Name your database and click OK.

Now set the authentication mode.

  1. In the management screen, right-click on the server node and select Properties.
  2. This will open the Server Properties window.
    In the Server Properties window, select Security from the page menu and click the SQL Server and Windows Authentication mode radio button.
  3. Click OK.

You Are Ready to Deploy

Those few steps are all the prerequisites you need to start the Web publishing process in LightSwitch. My next post will cover that process.

Tagged , ,