Click here to Skip to main content
14,453,349 members
   

ASP.NET

 
QuestionWhy can't I login to the web even though the User and password are correct ? Pin
Member 24584679-Jan-20 22:43
MemberMember 24584679-Jan-20 22:43 
AnswerRe: Why can't I login to the web even though the User and password are correct ? Pin
ZurdoDev10-Jan-20 2:00
mveZurdoDev10-Jan-20 2:00 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846714-Jan-20 17:19
MemberMember 245846714-Jan-20 17:19 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
ZurdoDev14-Jan-20 17:52
mveZurdoDev14-Jan-20 17:52 
AnswerRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming10-Jan-20 3:32
communityengineerRichard Deeming10-Jan-20 3:32 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846714-Jan-20 17:24
MemberMember 245846714-Jan-20 17:24 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming15-Jan-20 1:25
communityengineerRichard Deeming15-Jan-20 1:25 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846716-Jan-20 21:23
MemberMember 245846716-Jan-20 21:23 
You can log in, but in the code you've posted, you're not assigning any roles to the user.
Any calls to User.IsInRole will therefore return false.

ASP.NET 3.5 - Roles | Microsoft Docs[^]

I don't understand you saying "Any calls to User.IsInRole will therefore return false." Can you tell me where this is ? How do I edit the code? I debug in the button_click event code, I see
protected void btLogon_Click(object sender, EventArgs e)
        {            
            if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
            {
                try
                {
                    if (Request.QueryString["ReturnUrl"] != null)
                    {
                        FormsAuthentication.RedirectFromLoginPage(txtEmail.Text, false);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
                        Session["username"] = txtEmail.Text.Trim();
                        Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");//You see the message output in the attached image, I choose yes
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print("Error login sql: " + ex);
                }
            }
            else
            {
                try
                {
                // kiem tra xem co UserName hay ko 
                if (txtEmail.Text==ConfigurationManager.AppSettings["EmailWebmaster"].ToString() && txtPassword.Text == ConfigurationManager.AppSettings["Password"].ToString())
                {
                    FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
                    Session["username"] = txtEmail.Text.Trim();
                    Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");//You see the message output in the attached image, I choose yes
                }
                else
                    lblMsg.Text = ResourceManager.GetString("Logon_False");

                }
                catch (Exception ex)
                {
                    Debug.Print("Error Web.config: " + ex);
                }
            }

        }

I am debugging both the user/pass sql server and user/pass cases in the Web.config file when I came to the code "Response.Redirect (Globals.ApplicationPath +" Logon_Redirect.aspx ");" In both cases, a notification is sent to view the http://www.mediafire.com/view/wvlg2xymggvd6rj/ErrLoginFA.jpg/file attachment
When running this line with the corresponding user/pass will give an error message Debug.Print (...) corresponding to both cases. If the login user/password sql server can access, the login user/password Web.config cannot access although the login user/password sql server reports the above error via Debug.Print (..)

Error login sql: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.AbortCurrentThread()
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
at System.Web.HttpResponse.Redirect(String url)
at webapp4U.UI.Controls.Controls_MenuLeft.btLogon_Click(Object sender, EventArgs e) in c:\WebSite2010\Controls\Logon.ascx.cs:line 68

Error Web.config: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.AbortCurrentThread()
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
at System.Web.HttpResponse.Redirect(String url)
at webapp4U.UI.Controls.Controls_MenuLeft.btLogon_Click(Object sender, EventArgs e) in c:\WebSite2010\Controls\Logon.ascx.cs:line 85
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming17-Jan-20 1:30
communityengineerRichard Deeming17-Jan-20 1:30 
QuestionHow do you have a DropDownList populated without default selected item? Pin
Member 114033049-Jan-20 7:07
MemberMember 114033049-Jan-20 7:07 
AnswerRe: How do you have a DropDownList populated without default selected item? Pin
ZurdoDev9-Jan-20 7:40
mveZurdoDev9-Jan-20 7:40 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
Member 114033049-Jan-20 7:56
MemberMember 114033049-Jan-20 7:56 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
ZurdoDev9-Jan-20 8:59
mveZurdoDev9-Jan-20 8:59 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
Mycroft Holmes9-Jan-20 11:14
MemberMycroft Holmes9-Jan-20 11:14 
QuestionHow to I make EmailButton_Click work? Pin
Member 114033048-Jan-20 5:59
MemberMember 114033048-Jan-20 5:59 
AnswerRe: How to I make EmailButton_Click work? Pin
ZurdoDev8-Jan-20 6:21
mveZurdoDev8-Jan-20 6:21 
AnswerRe: How to I make EmailButton_Click work? Pin
F-ES Sitecore8-Jan-20 6:45
mveF-ES Sitecore8-Jan-20 6:45 
GeneralRe: How to I make EmailButton_Click work? Pin
Member 114033048-Jan-20 12:16
MemberMember 114033048-Jan-20 12:16 
GeneralRe: How to I make EmailButton_Click work? Pin
F-ES Sitecore8-Jan-20 23:11
mveF-ES Sitecore8-Jan-20 23:11 
QuestionHow do I make my GetCasesButton_Click work? Pin
Member 114033048-Jan-20 5:46
MemberMember 114033048-Jan-20 5:46 
AnswerRe: How do I make my GetCasesButton_Click work? Pin
ZurdoDev8-Jan-20 6:19
mveZurdoDev8-Jan-20 6:19 
GeneralRe: How do I make my GetCasesButton_Click work? Pin
Member 114033048-Jan-20 8:56
MemberMember 114033048-Jan-20 8:56 
QuestionHow do I make my GetCasesButton_Click work? Pin
Member 114033048-Jan-20 5:33
MemberMember 114033048-Jan-20 5:33 
AnswerRe: How do I make my GetCasesButton_Click work? Pin
ZurdoDev8-Jan-20 6:18
mveZurdoDev8-Jan-20 6:18 
QuestionText with Audio Pin
Member 104440587-Jan-20 22:19
MemberMember 104440587-Jan-20 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.