ASP.net(C#)的登陆问题(简单)

来源:百度知道 编辑:UC知道 时间:2024/06/07 04:35:32
起步学.net。练习一个简单的登陆功能,在主界面(index.aspx)一个登陆对话框,如果登陆成功则转向(http://localhost/LoginTest/Main.aspx);
否则转向
http://localhost/LoginTest/Fail.aspx);
现在有一个问题就是:如果我直接在URL中输入:http://localhost/LoginTest/main.aspx后,页面照样执行,就是说我做的登陆功能几乎没有用,怎么样才能防止URL直接登录呢?
在登录功能还有哪些需要注意的方面,请高人答复!!!谢谢!

后台:
private void 按钮_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if( 条件)
{//满足
Session["起个session名"] = 用户ID
this.Response.Redirect("http://localhost/LoginTest/Main.aspx");

}
else
{
this.Response.Redirect("http://localhost/LoginTest/Fail.aspx");
}
}

http://localhost/LoginTest/main.aspx页面
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Session["起个session名"] == null)
{
this.Response.Redirect("http://localhost/L