Congratulations! You have created your own Personal Web Site, which includes a home page, resume, and photo album. You can use the site as-is with some small customizations, such as adding your own content. In addition, you can add pages to the site. The following sections explain how to use the Personal Web Site. First we will mention a few important topics regarding the application and database configuration:
In the rest of the document we will describe several actions that you can do when the application is correctly configured:
NOTE: Sections marked important, have to be followed before you can start the application!
For F# to work correctly with ASP.NET it is needed to configure a CodeDOM provider
in the web.config
file. The file already includes section with the
configuration, but you need to update the assembly version to match the F# version
you installed (if you don't know the version, you can start FSI,
which prints the version when starting). Find the compiler
node in
the web.config
file and set the right version number (e.g. 1.9.2.2):
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true"> <compilers> <compiler language="F#;f#;fs;fsharp" extension=".fs" type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider, FSharp.Compiler.CodeDom, Version=<version number>, Culture=neutral, PublicKeyToken=a19089b1c74d0809"/> </compilers> </compilation> </system.web> </configuration>
If you want to configure a different ASP.NET project to use F#, you need to include the compiler section from this code snippet.
Before you can start using the application, you need to configure a database. This
application uses two separate databases - one to store user information managed
by the ASP.NET and second to store custom application data (Photos and Albums).
We describe two possible situations - you can either use SQL Server 2005 Express
edition and keep your database files in App_Data
directory or you can use different
SQL Server edition.
To use SQL Server 2005 Express
web.config
file and modify the connectionStrings section to include the following:
<connectionStrings> <add name="Personal" providerName="System.Data.SqlClient" connectionString= "Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString= "Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" /> </connectionStrings>
To use other SQL Server 2005 edition
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
personal-add.sql
file in
the App_Data directory and execute them to create database tables.web.config
file and modify the connectionStrings section to
include the following (note: this sample uses Windows authentication, to use different
authentication method you will need to modify the connection strings):
<connectionStrings> <add name="Personal" providerName="System.Data.SqlClient" connectionString= "Data Source=.;Integrated Security=True;Database=PWS_WebPersonal" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString= "Data Source=.;Integrated Security=True;Database=PWS_AspNetDb" /> </connectionStrings>
F# distribution currently doesn't supply F# page template, so if you want to create
a new page you'll have to workaround this limitation. The easiest way to do so is
to create a new text file (right click on the project, select Add New Item,
select Text File). Once you created two empty files (NewPage.aspx
and NewPage.aspx.fs
), you can copy the following code and start programming
ASP.NET applications in F#!
NewPage.aspx
<%@ Page Language="F#" AutoEventWireup="true" CodeFile="NewPage.aspx.fs" Inherits="FSharpWeb.NewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>New Page</title> </head><body>
<form runat="server"><div> <h1>New Page</h1> <!-- ASP.NET button with event handler declared in code-behind file --> <asp:Button id="btnClickMe" runat="server" click="ButtonClicked" Text="Click me!" /> </div></form> </body></html>
NewPage.aspx.fs
#light namespace FSharpWeb open System open System.Web open System.Web.UI open System.Web.UI.WebControls type NewPage = inherit System.Web.UI.Page as base val mutable btnClickMe : Button // initialize all controls to a null value new() = let init() = (Array.zero_create 1).[0] { btnClickMe = init(); } override this.OnLoad(e) = base.OnLoad(e); // Event handler for the button member this.ButtonClicked(sender, e) = this.btnClickMe.Text <- "Clicked!"
NOTE: Since F# doesn't currently support partial classes, you have to declare all controls manually in the code-behind file. This means that every control with runat attribute set to server and with id attribute must have corresponding field in the F# code-behind file. In this example the only control used is a btnClickMe.
The first step you must take is to create an administrative user. The administrative user has permission to upload photos and create albums.
To create an administrative user
The following sections provide basic information about how to administer the site.
Visitors to your site can register themselves on your site. You can make registered users into Friends, which gives them permission to view private photo albums.
To give users permission to view private photo albums
The photo album feature allows you to:
To create an album and add photos
To bulk upload photos into an album
When you are ready to share your Web site with others, you can copy it to your Web server. You need to know the File Transfer Protocol (FTP) address of your server, and if required, the user name and password you use.
ftp://ftp.servername/foldername