Getting Started

1. Open VWD and create a new Web site called "GeekSpeak" in the language of your choice.



VB

2. Download the files for this project and extract them into the GeekSpeak site folder created by VWD at the location you specified in the New Web Site dialog. 

3. Follow the SQL Express setup instructions to set up the GeekSpeak database, using the GeekSpeak.sql script in the downloaded files.

4. In the Solution Explorer, select the project. In the Solution Explorer toolbar click the Refresh icon. Your project should now look like this:

5. Select the View | Database Explorer menu command. In the Database Explorer, right-click Data Connections and select Add Connection. In the Add Connection dialog click Change. Select Microsoft SQL Server Database File, and then click OK. Click Browse and navigate to the GeekSpeak.mdf file, which for a default SQL Express installation is located at C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data. Click Open, and then click OK.

6. In the Solution Explorer, right-click app_code and select Add New Item. Add a new Class file named "PageBase" (followed by the extension of the language you are using, whether .cs, .vb or .js). Wrap the class declaration in a "GeekSpeak" namespace declaration.

7. Derive the class from Page and then add the following code to the class (in C#, make sure your public class looks like: "public class PageBase : System.Web.UI.Page" and that you add "namespace GeekSpeak" just above the Public class declaration):


Inherits System.Web.UI.Page
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
    If IsNothing(Session("UserName")) AndAlso User.Identity.IsAuthenticated Then
        Session("UserName") = User.Identity.Name
    End If

    If Not IsNothing(Session("Theme")) Then
        Dim ThemesDropDownList As DropDownList = _
            CType(Page.Master.FindControl("themesDropDownList"), DropDownList)

        ThemesDropDownList.SelectedValue = Session("Theme").ToString()
        Page.Theme = ThemesDropDownList.SelectedValue
    Else
        Page.Theme = "Arctic Ice"
    End If
End Sub
VB

8. In the Solution Explorer, delete Default.aspx. Add a new Web Form to the project that references Public.master and also uses codebehind. Name it "Default.aspx". In its codebehind file, in the class declaration, change "System.Web.UI.Page" to "GeekSpeak.PageBase". In the same way, add a new Web Form called "Blog.aspx". Finally, right-click the project and select New Folder, naming it "MyBlog". Right-click the new folder and add a new Web Form called "Default.aspx", again in the same way.

9. Add a new Web Form that references Public.master but which does not use codebehind. Name it "BlogList.aspx". Open the new page in Source view and add the following to the Page directive: Inherits="GeekSpeak.PageBase". In the same way add three more pages: "Login.aspx", "RecoverPassword.aspx" and "Signup.aspx". Your project should now look like this:

10. Select Default.aspx and then press F5 to run the application. In a C# project, when prompted to add a new Web.config file with debugging enabled, click OK.

VB

C#

11. When the page loads, close your browser.

12. Right-click MyBlog and add a new Web Configuration File named "web.config". In the <system.web> element add the following:

<authorization>
   <deny users="?" />
</authorization>

13. Open the root web.config file and in the <authentication> element change "Windows" to "Forms".

14. After </system.web> add the following, replacing "machine-name" with your machine's name or "localhost":

<system.net>
   <mailSettings>
      <smtp deliveryMethod="Network">
         <network from="admin@geekspeak.com" host="machine-name" defaultCredentials="true" />
      </smtp>
   </mailSettings>
</system.net>

15. Add a new Site Map file to the project. Replace the two existing child siteMapNode elements with the following:

<siteMapNode title="Public Blogs" url="Default.aspx" />
<siteMapNode title="Member Blogs" url="BlogList.aspx" />
<siteMapNode title="My Blogs" url="Blog.aspx?un=lookup" />
<siteMapNode title="Add/Edit Blogs" url="MyBlog" />
 
HyperLink

Powered By ASP.NET v2.0