直接通过login.aspx页面在loggin上找不到HTTP 404 [英] http 404 not found on loggin through login.aspx page directly

查看:181
本文介绍了直接通过login.aspx页面在loggin上找不到HTTP 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有tw0页

default.aspx和login.aspx.

在登录页面上,我输入用户名和密码..问题是当我直接调试login.aspx页面时.错误出现http 404未找到

但是,当我调试(运行)default.aspx页面并单击登录li nk(登录链接的代码在下面)时.这会将页面重定向到login.aspx,然后在我输入用户名和密码后,它可以正常工作..为什么login.aspx页面无法直接工作

我在default.aspx页面上有登录链接

我将代码放在default.aspx页面上的登录链接中,并将页面重定向到login.aspx

i have tw0 pages

default.aspx and login.aspx.

on login page i enter username and password.. the problem is that when i directly debug the login.aspx page . error come http 404 not found

but when i debug ( run) default.aspx page and click on the login link( code for login link is below). which redirects the page to the login.aspx and after that when i enter username and password it works fine.. why login.aspx page is not working directly

i have login link on default.aspx page

i put the code in login link which is on default.aspx page and it redirect the page to login.aspx

protected void lnklogin_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Session.Abandon();

        // clear authentication cookie
        HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
        cookie1.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie1);

        // clear session cookie (not necessary for your current problem but i would recommend you do it anyway)
        HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
        cookie2.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie2);

        FormsAuthentication.RedirectToLoginPage();
        
    }




它会将我重定向到登录页面...


在登录页面上,我有一个代码





it will redirect me to the login page...


on login page i have a code


 ecprops _user = new ecprops();
         dbcon dbo = new dbcon();
        _user = dbo.CheckUser(txtUserid.Text);
        if (_user != null)
        {
            if (_user.Password == txtPassword.Text)
            {
                FormsAuthenticationTicket Authticket = new FormsAuthenticationTicket(
                                                        1,
                                                        txtUserid.Text,
                                                        DateTime.Now,
                                                        DateTime.Now.AddMinutes(30),
                                                        chkRemeberMe.Checked,
                                                        _user.RoleName,
                                                        FormsAuthentication.FormsCookiePath);

                string hash = FormsAuthentication.Encrypt(Authticket);

                HttpCookie Authcookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);

                if (Authticket.IsPersistent) Authcookie.Expires = Authticket.Expiration;

                Response.Cookies.Add(Authcookie);

                string returnUrl = Request.QueryString["ReturnUrl"];
                if (returnUrl == null) returnUrl = "/";

                Response.Redirect(returnUrl);

                
            }
            else
            {
                lblMessage.Text = "Password does'nt match.";
            }
        }
        else
        {
            lblMessage.Text = "User not exists.";


i put the fallwoing in webconfig

<pre lang="HTML"><<pre>authentication mode="Forms">
        <forms loginUrl="login.aspx"
          name=".ASPXAUTH"
          protection="All"
               timeout="90" slidingExpiration="true"></forms>
      </authentication>
      <authorization>
        <allow users="*"/>
      </authorization

>
}



>
}














public ecprops CheckUser(string UserName)
        {
            MAconn = new SqlConnection(connectionString);
            const string SP_CHECKUSER = "CheckUser";
            MAconn.Open();
            MAcmd = new SqlCommand(SP_CHECKUSER, MAconn);
            MAcmd.CommandType = CommandType.StoredProcedure;
            MAcmd.Parameters.Add("@UserName", DbType.String).Value = UserName;
            dr = MAcmd.ExecuteReader();
           ecprops _user = null;
            while (dr.Read())
            {
                _user = new ecprops();
                _user.Password = dr["Password"].ToString();
                _user.RoleName = dr["RoleName"].ToString();
            }
            return _user;
        }

推荐答案



据我所知,您必须在login.aspx页面加载方法中写一些错误

或登录按钮事件中出现一些代码错误.我不熟悉表单身份验证

那是我现在无法检查您的代码,但是我的反对只是检查login.aspx页中的页面加载方法代码.
Hi,

Upto my knowledge you''ve to wrote something error in login.aspx pageload method

or some code error in login button event.I''m not familier with form authentication

that''s y I''m unable to check your code now,but my sujestion is just check your pageload method code in login.aspx page.


也许是〜/Login.aspx" .通过仅声明login.aspx并且您不在IIS的文件夹结构中,很可能他找不到该页面.
perhaps "~/Login.aspx". By only stating login.aspx and you don''t where youa re in your folderstructure at IIS it is very possible he cannot find the page.


这篇关于直接通过login.aspx页面在loggin上找不到HTTP 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆