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…
- In LightSwitch, click Build>Publish to open the LightSwitch Publish Application Wizard.
- 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.
- 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.
- 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.
- 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).