Getting Started

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

C# 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 //<derive...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//公共类声明):

C# VB  
protected void Page_PreInit(object sender, EventArgs e)
            {
            if (Session["UserName"] == null && User.Identity.IsAuthenticated)
            {
            Session["UserName"] = User.Identity.Name;
            }
            if (Session["Theme"] != null)
            {
            DropDownList ThemesDropDownList = ((DropDownList)(Page.Master.FindControl("themesDropDownList")));
            ThemesDropDownList.SelectedValue = Session["Theme"].ToString();
            Page.Theme = ThemesDropDownList.SelectedValue;
            }
            else
            {
            Page.Theme = "Arctic Ice";
            }
            }
            

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" />
 

posted on 2007-04-13 15:44  改变热爱  阅读(253)  评论(0)    收藏  举报

导航