Solved

login control

Posted on 2009-05-11
21
217 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
  • 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now