IIS发布网页的基本操作
生活随笔
收集整理的這篇文章主要介紹了
IIS发布网页的基本操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前提是IIS已經安裝;
在運行框輸入下圖字符串,回車;進入到IIS管理器;
在D盤inetpub目錄下新建一個demo1文件夾,把要發布的兩個文件放入;
在IIS管理器右擊 網站 節點,添加網站...;
自己起一個網站名稱;物理路徑選擇前面的目錄;C或D盤的inetpub目錄是IIS默認的發布目錄;
端口找一個沒有使用的;其他默認;確定;
之后新建的網站就出來了;
在IIS管理器右側,操作列表,選擇 瀏覽網站,瀏覽 *:8019;
瀏覽器打開localhost:8019,在其后輸入/demo1.aspx,就看到了頁面的效果;
這是一個基本的網頁查詢顯示數據庫程序;
demo1.aspx;
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demo1.aspx.cs" Inherits="demo1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title></title> </head> <body><form id="form1" runat="server"><div><asp:GridView ID="GridView1" runat="server"></asp:GridView></div></form> </body> </html>demo1.aspx.cs;
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;public partial class demo1 : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e){//IsPostBack只有在第一次打開的時候是false,其它時候都是trueif (!IsPostBack){databind();}}void databind(){SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=hatcher;User Id=sa;Password=kxxxxxb;");SqlCommand MyCommand = new SqlCommand("SELECT * FROM advpeoples", conn);SqlDataAdapter SelectAdapter = new SqlDataAdapter();SelectAdapter.SelectCommand = MyCommand;DataSet MyDataSet = new DataSet();conn.Open();SelectAdapter.SelectCommand.ExecuteNonQuery();SelectAdapter.Fill(MyDataSet);GridView1.DataSource = MyDataSet.Tables[0];GridView1.DataBind();conn.Close();} }總結
以上是生活随笔為你收集整理的IIS发布网页的基本操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Bing Maps Geographic
- 下一篇: C# Marshal类基本概念和入门示例