登录页面没有重定向到asp.net mysql中的报告页面 [英] login page not redirect to reports page in asp.net mysql

查看:38
本文介绍了登录页面没有重定向到asp.net mysql中的报告页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用usertype登录并重定向到他们的页面,例如管理员重定向到报告页面和公共用户重定向到图库..



当我尝试从管理员用户名和密码然后没有发生..点击登录按钮页面重定向登录页面,而不是重定向到报告页面,我想在管理员登录时,然后他们重定向到报告页面



而当我使用公共用户名和密码登录时,它会重定向到图库页面..



这里是代码



  protected   void  Button1_Click1( object  sender,EventArgs e)
{
name = TextBox1.Text.Trim();
pwd = TextBox2.Text.Trim();
conn.Open();
MySqlCommand cmd = new MySqlCommand( select ln.UName,ln.UPasword,来自登录ln的ut.UserType_ID,UserType ut其中ln.UName =' + name + '和ln.UPasword =' + pwd + '和ln。 UserType_ID = ut.UserType_ID);
cmd.Connection = conn;
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
会话[ UName] = dr [ 0 ] .ToString();

会话[ UPasword] = dr [ 1 ] .ToString();
会话[ UserType_ID] = dr [ 2 ] .ToString();


}

if (dr [ 2 ]。ToString()== 1
{
Response.Redirect( View_Reports.aspx);
}
else
{
Response.Redirect( gallery.aspx);
}

dr.Close();
conn.Close();
}





有什么帮助吗?

解决方案

在这种情况下我可以想到两种可能性



1)你的查询没有返回任何行,这意味着你没有管理员用户在您输入凭据的数据库中。



2)报告页面中可能有重定向。


什么我想说的是



数据库中可能有用户但不确定管理员用户是否使用了您正在使用的用户和密码。



请检查View_Reports.aspx中是否有任何重定向到登录页面。


if(dr [2 ] .ToString()==1)

{



你能检查以上条件,我认为控制可能不是进入它。你可以检查数据库中的UserType是否为1并且没有空格。

i try to login with usertype and redirect to their pages e.g admin redirect to reports page and public user redirect to gallery..

when i try to login from admin username and password then nothing happened.. when click on login button page redirect login page and not redirect to reports page where as i want when admin login then they redirect to reports page

whereas when i login with public user name and password it redirect to gallery pages ..

here is the code

protected void Button1_Click1(object sender, EventArgs e)
       {
           name = TextBox1.Text.Trim();
        pwd = TextBox2.Text.Trim();
        conn.Open();
     MySqlCommand cmd = new MySqlCommand("select ln.UName, ln.UPasword, ut.UserType_ID from login ln, UserType ut where ln.UName = '" + name + "' and ln.UPasword = '" + pwd + "' and ln.UserType_ID = ut.UserType_ID");
    cmd.Connection = conn;
    MySqlDataReader dr = cmd.ExecuteReader();
   if ( dr.HasRows )
    {
   dr.Read( );
   Session[ " UName" ] = dr[ 0 ].ToString( );

   Session[ " UPasword" ] = dr[ 1 ].ToString( );
   Session[ "UserType_ID" ] = dr[ 2 ].ToString( );


     }

   if (dr[2].ToString() == "1")
       {
          Response.Redirect( "View_Reports.aspx" );
        }
       else
      {
      Response.Redirect( "gallery.aspx" );
        }

        dr.Close();
        conn.Close();
    }



any help please?

解决方案

I can think of two possibilities in this scenario

1)Either your query is not returning any rows,which means that you don't have the admin user in the database with the credentials you are entering.

2) There might be a redirection in the reports page.


What I am trying to say is

There might be users in the database but not sure if the admin user ,with the user and password that you are using is there.

Could you please check if there is any redirection in the View_Reports.aspx to the login page.


if (dr[2].ToString() =="1")
{

Can you check the above if condition ,I think control might not be going in it.Can you check if the UserType is "1" in the database and there are no spaces.


这篇关于登录页面没有重定向到asp.net mysql中的报告页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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