Link to home
Start Free TrialLog in
Avatar of jtran007
jtran007

asked on

login control

Hi Expert,
I use login control in the login page. When I run in
the Visual IDE, it starts with login page. Then I type usernam, and
password. If it passes, I go to the other page (called dialcode.aspx).
However if i run in the browser (firefox), it always go to my dialcode page.
Could you help?
Thx,
JT
Avatar of urir10
urir10

Is your web.config file set to redirect the user if the user is not logged in?
		<authentication mode="Forms">
			<forms loginUrl="login.aspx" protection="All" timeout="180" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="false" defaultUrl="~/Default.aspx" cookieless="UseDeviceProfile"/>
		</authentication>
		<authorization>
			<deny users="?"/>
		</authorization>

Open in new window

Avatar of jtran007

ASKER

Hi expert,

How is web.config working; since I am new to web app.
Thx,
JT
SOLUTION
Avatar of urir10
urir10

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi expert,
I copied your attached code, and put into my web.config. It's not working; it did not
allow me to go to another page either.

What do I have to change your code?
Thx,
JT
Hi expert,
Attached is my added in the web.config.When I click login,
nothing happens.

Please help.
Thx,
JT
 <authentication mode="Forms">
 
      <forms loginUrl = "Login.aspx" name="3345C" timeout="1"/>
 
    </authentication>

Open in new window

Can you share the code how you are authenticating the user?
Are you using Membership Provider?
Make sure browser cookies is enabled.
Are you having any roles?

Please share all relevant code.
Hi expert,
Yes, I can.
No I am using membership provider.
What are cookies for?
No I don't have any roles.
Just create user name, and password. And let them
use my web app. That's all ai want.
Thx,
Jt
        protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
        {
            bool Authenticated = false;
            Authenticated = Authenmethod(Login1.UserName, Login1.Password);
            e.Authenticated = Authenticated;
            if (Authenticated == true)
            {
                Response.Redirect("dialcode.aspx");
            }
 
        }
        private bool Authenmethod(string UserName, string Password)
        {
            if (UserName.Equals("qiiq") && Password.Equals("abc"))
                return true;
            else
                return false;
        }

Open in new window

----What are cookies for?
FormsAuthentication requires cookies enabled by default...So check you browers accept cookies...
With FireFox .. Got to Tools->Options->Privacy Tab -> Make sure Accept cookies from site Checkbox is Selected.

Might sound stupid to ask...but make sure you are entering correct username and password...i.e. by mistake you are not entering leading or trailing spaces....

Also Drag and drop LoginName and LoginStatus control on your Login.aspx page for troubleshooting purpose.
Oh yeah also make sure you are denying anonymous access to your website ...i.e. add this to your web.config:

<authentication mode="Forms">
   <forms loginUrl = "Login.aspx" name="3345C" timeout="1"/>
    </authentication>
<authorization>
      <deny users="?"/>
    </authorization>
Hi expert,

Yes I did include it in the web.config.
Somehow I run in the Visual IDE, it's workin fine but not
in the browser.

Thx,
JT
There is one problem i found with your code.
You have e.Authenticated = Authenticated;    outside the if statement so the user is always Authenticated= true.
Do it like that
 protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
        {
            bool Authenticated = false;
            Authenticated = Authenmethod(Login1.UserName, Login1.Password);
            
            if (Authenticated == true)
            {
                e.Authenticated = Authenticated;
                Response.Redirect("dialcode.aspx");
            }
 
        }
        private bool Authenmethod(string UserName, string Password)
        {
            if (UserName.Equals("qiiq") && Password.Equals("abc"))
                return true;
            else
                return false;
        }

Open in new window

Hi expert,

guru_sami:
I did check Firefox.its setting is ok as you said.
Also in the web.config, I do include .
But the result is still the same.

Thx,
JT
Hmm.. Lets see it again....
When you say:
"However if i run in the browser (firefox), it always go to my dialcode page."
Does same thing happens when you try it in IE?
Do you mean after logging or directly to dialcode.aspx without logging-in?
Did you try placing LoginName Control on your Login.aspx page? What do you see when you start your website first.
Can you also place a LoginName control on your dialcode page and let us know what you see.
 
Hi expert,
No, when I run in IDE, the login starts first. Then if the authentication is OK,
user is allowed to the other page.
The logging happens only in the login page, not in the dialcode page.
The result I told you so far is that login control is in the login page .
If you want to try login control in the dialcode page, I'll do. But not my
intention.

Regards,
JT
I think you misunderstood about LoginName control...
Login Control and LoginName Control are two different control.
So I am suggesting you to place LoginName control in your Login.aspx(which also has Login Control)
and your Dialcode.aspx(which will have just LoginName control and not Login control).

Check this: http://www.dotnetjunkies.ddj.com/QuickStartv20/aspnet/doc/ctrlref/login/loginname.aspx
and when I say:
Does same thing happens when you try it in IE?

I mean Internet Explorer (IE) as you mentioned firefox specifically so just wondering if it is working fine with IE.
Hi expert,

Since I have a  lot of controls in the dialcode page. Now I put login control in this page, other
controls must be disabled, and enable when authentication is verified.
Is it possible to have login in the login page, and my othe controls in the dialog page?
Thx,
JT
Did you get my last post....I still confirm ...login Control and LoginName control are two different controls.
Hi expert,

I did get your last post; however I went home at 5:30PM. Now I return your
post from home. How do I use login control name?

Thx,
JT
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial