ASP .NET C# 入门 登陆示例 最纯的代码

作者在 2010-09-08 17:33:55 发布以下内容
  源文件:login.html和welcome.aspx。
示例功能:登陆页面提交用户名和密码到welcome.aspx,
               welcome.aspx做简单的验证后,给予回应
 
发句牢骚,不喜欢的同学,直接跳过,看下面的代码。
很简单的玩意,在网上和书上找到的,都是一堆代码,无语!希望,我提供的代码够简洁。不足之处,麻烦您修改后,提供给大家(你就是原创了)
 
 请尊重他人的劳动,转载注明出处

 
---1-----------登陆页面:login.html------------------------------------
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登陆页面</title>
</head>
<body>
<form method="post" action="welcome.aspx">
    用户名:<input type="text" name="userName"  />
  <p>
      密码:<input type="password" name="password"  />
     </p>
  <p>
       <input type="submit"  value="提交" />
       <input type="reset"  value="重置" />
     </p>
</form>

</body>
</html>
---2-----------欢迎页面:welcome.aspx------------------------------------
 
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎页面</title>
</head>
<body>
<%
 string userName = Request["userName"];
    string password = Request["password"];
    if ("".Equals(userName) || userName == null || "".Equals(password) || password == null)
    {  
       
        Response.Redirect("login.html",true);       
    }   
   
Response.Write(userName + "  " + password);
%>
</body>
</html>
---------------------------------------
有些同学使用了我的代码后,可能会出现乱码的问题。我的页面是使用Dreamweaver编辑的,charset=utf-8!!
如果真的乱码了的话,建议,把所有的utf-8都替换为gbk
2010-09-06

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/javaliyuanyuan/archive/2010/09/06/5867181.aspx
.net 编程 | 阅读 628 次
文章评论,共0条
游客请输入验证码
文章归档
最新评论