Click here to Skip to main content
14,697,672 members
Home » Discussions » ASP.NET
   

ASP.NET

 
AnswerMessage Closed Pin
23-Mar-20 4:09
MemberNerea Clark23-Mar-20 4:09 
QuestionHtmlagilitypack -- I'm stuck Pin
Member 175325011-Jan-20 6:40
MemberMember 175325011-Jan-20 6:40 
QuestionHow do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
Member 1140330410-Jan-20 10:19
MemberMember 1140330410-Jan-20 10:19 
AnswerRe: How do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
Richard MacCutchan10-Jan-20 12:37
mveRichard MacCutchan10-Jan-20 12:37 
AnswerRe: How do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
ZurdoDev11-Jan-20 10:03
mveZurdoDev11-Jan-20 10:03 
QuestionHow do I fix 'object' does not contain a definition for 'Value'? Pin
Member 1140330410-Jan-20 9:27
MemberMember 1140330410-Jan-20 9:27 
AnswerRe: How do I fix 'object' does not contain a definition for 'Value'? Pin
ZurdoDev10-Jan-20 10:09
mveZurdoDev10-Jan-20 10:09 
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 
I am writing a small example of Login webSite, there are two types of accounts and passwords, one is an account and password is stored in the Web.config file and the other two accounts and passwords are saved in SQL Server database, My problem is that in form 1, when logging in it opens Logon_Redirect.aspx file but cannot access, the following is my code
I am debugging and running to the code where this opens the Logon_Redirect.aspx file but nothing, but when I log in with another account and password (the user password of SQL Server) log in well.
In file Web.config
<appSettings>
...
<add key="SmtpServer" value="localhost"/>
<add key="EmailWebmaster" value="admin"/>
<add key="Password" value="123"/>
...
</appSettings>

 In file Logon_Redirect.aspx
... 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

In file Logon_Redirect.aspx.cs
... 
public partial class Logon_Redirect : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
    {
          // kiem tra va Redirect toi trang can thiet
          if (Page.User.IsInRole(Globals.Settings.AppRoles.KhachHang))
          Response.Redirect(Globals.ApplicationPath);
          else if (Page.User.IsInRole(Globals.Settings.AppRoles.Admin))
          Response.Redirect(Globals.ApplicationPath + "WebMaster/Contacts/Contact.aspx");
     }
}

In file Logon.aspx.cs  
protected void btLogon_Click(object sender, EventArgs e)
{
     //I can't Login User/Pass in file Web.config, check User: admin and Pass: 123
     if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
     {            
            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");
          //I am debugging and running to the code here and opens the Logon_Redirect.aspx file but nothing 
    }
    }
   else  //Login SQL Server very good
   {
          // check User/pass other on SQL Server
          if (webapp4U.BOL.User.CheckUserName(txtEmail.Text) && txtPassword.Text ==             ConfigurationManager.AppSettings["Password"].ToString())
          {
                 FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
                 Session["username"] = txtEmail.Text.Trim();
                 Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");
         }
        else
                lblMsg.Text = ResourceManager.GetString("Logon_False");
     }
}

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
mveRichard 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
mveRichard 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 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming17-Jan-20 1:30
mveRichard 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
professionalMycroft 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 

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.