Solved

login control

Posted on 2009-05-11
21
222 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:jtran007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 3
  • +1
21 Comments
 
LVL 7

Expert Comment

by:urir10
ID: 24356409
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

0
 

Author Comment

by:jtran007
ID: 24356617
Hi expert,

How is web.config working; since I am new to web app.
Thx,
JT
0
 
LVL 7

Assisted Solution

by:urir10
urir10 earned 30 total points
ID: 24356647
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:jtran007
ID: 24356732
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
0
 

Author Comment

by:jtran007
ID: 24356931
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

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24356965
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.
0
 

Author Comment

by:jtran007
ID: 24357401
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

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24357637
----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.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24357673
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>
0
 

Author Comment

by:jtran007
ID: 24357921
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
0
 
LVL 7

Expert Comment

by:urir10
ID: 24357948
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

0
 

Author Comment

by:jtran007
ID: 24357953
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
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24358712
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.
 
0
 

Author Comment

by:jtran007
ID: 24358923
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
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24358971
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
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24359006
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.
0
 

Author Comment

by:jtran007
ID: 24359012
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
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24359830
Did you get my last post....I still confirm ...login Control and LoginName control are two different controls.
0
 

Author Comment

by:jtran007
ID: 24360686
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
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 70 total points
ID: 24365207
just drag and drop LoginName control from VS Toolbox on your Login.aspx and dialcode.aspx.
Thats it nothing else. No coding.
The reason for using this is I just want to make sure if there is session alive and you are staying logged-in somehow.
0
 
LVL 6

Accepted Solution

by:
M3mph15 earned 150 total points
ID: 24370759
Hi,

What you could do is add a variable to the session when they login.....for example their username or somethign like that.

E.g. String usr = <username> ;
         Session.Add('AuthUser', usr); //AuthUser is the name of the object in the session, it can be changed to whatever suits you. usr is the name of the variable we are adding to the session.

Then in the Page_Load method of dialcode.aspx check if the variable in the session exists. If so then the user has logged in. If not then either the user has not logged in or the session has expired so redirect them to the login page.

string usr = Session("AuthUser");
if usr = null or usr.Length = 0 then
{
         Response.Rediect("Login.aspx");
}

Syntax may be a bit off....coding off the top of my head....not at a computer where i can test this.

That way the user will not be able to access the page without logging in. This can be used in any page the same way.

HTH
-M3mph15
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question