将asp.net本页面转为静态页面html

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.message.Text = "";
        Head1.index = 3;
        Nav1.Nav = "登陆";
        this.Title = Common.Title + "会员登陆";
        if (!IsPostBack)
        {
            if (Request.QueryString["url"] != null)
                hid_url.Value = Request.QueryString["url"].ToString();
        }
    }

    protected void Btn_login_Click(object sender, ImageClickEventArgs e)//立即登入按钮
    {
        string username = this.username.Value;
        string pwd = this.pwd.Value;
        pwd = zhan.Normal.Common.CreatePassword(pwd, zhan.Enums.CurrentEnum.SecurityPassword.MD5).ToLower();

        string sql = "select * from tbl_member where username=@username and pwd=@pwd ";
        SqlParameter[] param ={
        new SqlParameter("@username",SqlDbType.VarChar,20),
        new SqlParameter("@pwd",SqlDbType.VarChar,100)
        };
        param[0].Value = username;
        param[1].Value = pwd;
        DataSet ds = zhan.Data.Sql.SqlHelper.ExecuteDataSet(CommandType.Text, sql, param);
        if (ds.Tables[0].Rows.Count == 1)
        {
            Session["mobile"] = ds.Tables[0].Rows[0]["mobile"].ToString();
            Session["memberid"] = ds.Tables[0].Rows[0]["id"].ToString();
            Session["nickname"] = ds.Tables[0].Rows[0]["nickname"].ToString();
            Session["username"] = ds.Tables[0].Rows[0]["username"].ToString();

            //自动登录
            if (chklogin.Checked)
            {
                Response.Cookies["member"]["mobile"] = ds.Tables[0].Rows[0]["mobile"].ToString();
                Response.Cookies["member"]["memberid"] = ds.Tables[0].Rows[0]["id"].ToString();
                Response.Cookies["member"]["nickname"] = ds.Tables[0].Rows[0]["nickname"].ToString();
                Response.Cookies["member"]["username"] = ds.Tables[0].Rows[0]["username"].ToString();
                Response.Cookies["member"].Expires = DateTime.Now.AddDays(1d);
            }

            //登录一次增加1个积分
            try
            {
                string msg = "";
                Common.DoPoint(int.Parse(ds.Tables[0].Rows[0]["id"].ToString()), 2, 0, out msg);
            }
            catch
            { }
            if (string.IsNullOrEmpty(hid_url.Value))
                Response.Redirect("Index.aspx");
            else
                Response.Redirect(hid_url.Value);
          
        }
        else
        {
            this.message.Text = "<script>alert('用户名号或密码错误');</script>";
        }
    }


    protected override void Render(HtmlTextWriter writer)
    {
        System.IO.StringWriter html = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(html);
        base.Render(tw);
        System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("index.html"), false, System.Text.Encoding.Default);
        sw.Write(html.ToString());
        sw.Close();
        tw.Close();
        //Response.Write("页面生成成功!");
        Response.Redirect("index.html");

    }
}

posted @   94cool  阅读(284)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2009年7月 >
28 29 30 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示