Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Thursday, March 29, 2012

Newbie -- Page_Load( ) fires twice if image is added to Login page

Hi,
I'm using Visual Studio 2005 + ASP.NET and C#
I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)
With a "template" loginCtl the Page_Load( ) event fires once.
As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.
If I remove the image, then these methods are only fired once.
Any ideas?
I am setting the event delegate like this in my login.aspx.cs file:
protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}
protected void Page_Load( ... etc.
Thanks for any tips,
FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)

Newbie -- Page_Load( ) fires twice if image is added to Login page

Hi,

I'm using Visual Studio 2005 + ASP.NET and C#

I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)

With a "template" loginCtl the Page_Load( ) event fires once.

As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.

If I remove the image, then these methods are only fired once.

Any ideas?

I am setting the event delegate like this in my login.aspx.cs file:

protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}

protected void Page_Load( ... etc.

Thanks for any tips,

FrankThis isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)

Monday, March 26, 2012

Newbie ? - Error on Redirect from login page error

Hello all,
Trying to make a login page to a website. However I don't the user to be
able to set a password, I want to control the password for everbody, and
change it wly. Any way, I have found alot of docs on Form Authentication
to be used as a login page. But they all are a little diffrent, and always
cover the highlights. I would love to see something that takes me from poin
t
A to Point B. Anyway's, I have been making some progress, although slower
than I would like. So here is a snippet of my code for my login button.
Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogIn.Click
' Server.Transfer("main.aspx") used to go to main page
Session("User Name") = txtUN.Text
Session("Password") = txtPW.Text
FormsAuthentication.RedirectFromLoginPage(txtUN.Text, False)
End Sub
And here is my web config code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<location path="ProtectMe.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<system.web>
<httpHandlers>
<add verb="*" path="Users.xml"
type="System.Web.HttpForbiddenHandler"/>
</httpHandlers>
<authentication mode="Forms">
<forms name="ImsApp"
loginUrl="localhost/mmgims/Login1.aspx" protection="all"/>
</forms>
</authentication>
</system.web>
</configuration>
It is my understanding that the redirectfromloginpage should take me to the
login page if the password or User name is wrong. But this is what I get for
an error
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure that
it is spelled correctly.
Requested Url: /mmgims/default.aspx
I don't have a default page, I have the login page, and the main page which
would be my home page. Again, I been taking a little bit of info from
everywhaere.
Any advise would be great!!!
Thanks to all!!!
RudyI think your problem is the loginUrl in your web.config.
Make this path relative to the web.config
so your web.config is under the root, and your login page is under
mmgims directory make it this:
loginUrl="mmgims/Login1.aspx"
leave the localhost part out of there. your page is redirecting how it
should, but it can't find the login page you specified.
let me know if that works.
DKode
Thanks for the tip, that does make sense! I'll try it out tonite and let you
know.
Rudy
"DKode" wrote:

> I think your problem is the loginUrl in your web.config.
> Make this path relative to the web.config
> so your web.config is under the root, and your login page is under
> mmgims directory make it this:
> loginUrl="mmgims/Login1.aspx"
> leave the localhost part out of there. your page is redirecting how it
> should, but it can't find the login page you specified.
> let me know if that works.
> DKode
>
thanks DKode, that did the trick!
"Rudy" wrote:
> Thanks for the tip, that does make sense! I'll try it out tonite and let y
ou
> know.
> Rudy
> "DKode" wrote:
>

Newbie ? - Error on Redirect from login page error

Hello all,

Trying to make a login page to a website. However I don't the user to be
able to set a password, I want to control the password for everbody, and
change it weekly. Any way, I have found alot of docs on Form Authentication
to be used as a login page. But they all are a little diffrent, and always
cover the highlights. I would love to see something that takes me from point
A to Point B. Anyway's, I have been making some progress, although slower
than I would like. So here is a snippet of my code for my login button.
Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogIn.Click
' Server.Transfer("main.aspx") used to go to main page
Session("User Name") = txtUN.Text
Session("Password") = txtPW.Text

FormsAuthentication.RedirectFromLoginPage(txtUN.Te xt, False)
End Sub

And here is my web config code
<?xml version="1.0" encoding="utf-8" ?>
<configuration
<location path="ProtectMe.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location
<system.web
<httpHandlers>
<add verb="*" path="Users.xml"
type="System.Web.HttpForbiddenHandler"/>
</httpHandlers
<authentication mode="Forms">
<forms name="ImsApp"
loginUrl="localhost/mmgims/Login1.aspx" protection="all"/
</forms>
</authentication
</system.web>
</configuration>
It is my understanding that the redirectfromloginpage should take me to the
login page if the password or User name is wrong. But this is what I get for
an error

Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure that
it is spelled correctly.

Requested Url: /mmgims/default.aspx

I don't have a default page, I have the login page, and the main page which
would be my home page. Again, I been taking a little bit of info from
everywhaere.

Any advise would be great!!!

Thanks to all!!!

RudyI think your problem is the loginUrl in your web.config.

Make this path relative to the web.config

so your web.config is under the root, and your login page is under
mmgims directory make it this:

loginUrl="mmgims/Login1.aspx"

leave the localhost part out of there. your page is redirecting how it
should, but it can't find the login page you specified.
let me know if that works.

DKode
Thanks for the tip, that does make sense! I'll try it out tonite and let you
know.

Rudy

"DKode" wrote:

> I think your problem is the loginUrl in your web.config.
> Make this path relative to the web.config
> so your web.config is under the root, and your login page is under
> mmgims directory make it this:
> loginUrl="mmgims/Login1.aspx"
> leave the localhost part out of there. your page is redirecting how it
> should, but it can't find the login page you specified.
> let me know if that works.
> DKode
>
thanks DKode, that did the trick!

"Rudy" wrote:

> Thanks for the tip, that does make sense! I'll try it out tonite and let you
> know.
> Rudy
> "DKode" wrote:
> > I think your problem is the loginUrl in your web.config.
> > Make this path relative to the web.config
> > so your web.config is under the root, and your login page is under
> > mmgims directory make it this:
> > loginUrl="mmgims/Login1.aspx"
> > leave the localhost part out of there. your page is redirecting how it
> > should, but it can't find the login page you specified.
> > let me know if that works.
> > DKode

Friday, March 16, 2012

Newbie needing a little help getting started

I need to make a redirect page that will pass over an id and password to a diffrent site (universal login)
Well my company already has 2 of them (which i did not make either of them) and now I am being thrust into making them (and i barely know asp.net)
My boss told me where to get the files but when i try to open them it gives me an error saying "Unable to get project from web server"
I am trying to open the old .net files so i can see how they were made so i can pretty much use the same code just tell it to go to a diffrent page
Can anyone help me open the files or maybe point me in the right direction on how to make my own universal logins?
Well, the question is not clear.
You said you opened the old .net files, couldn;t you understand what was going on? Redirecting to another page on another server?
regards

If you can't open the files on the web server, have you tried copying the project over to your computer and opening it locally in visual studio.net?
smtraber
Here is the thing...
My boss made it on his pc, he put the project up in a folder that I have access to on our network.
I pulled it down and now i can not open it.
My question is how to open the project.
and i also have another question, which is can someone point me in the direction on how to make universal links.

smtraber wrote:

If you can't open the files on the web server, have you tried copying the project over to your computer and opening it locally in visual studio.net?
smtraber


yes i have tried copying the file to my own pc, but it still is not working.
i really need to get this file open. Everything i try it keeps saying " Unable to get project from the web serever "


I'm not sure if this will solve your problem, but I read somewhere this can be solved if you:
1. Delete the project file from your LOCAL computer and remove the virtual directory
2. Create a new ASP.net web project in visual studio, which will also create a new virtual directory
3. Copy the files in the project from your web server over to the project folder you just created in inetpub, then try to open them
Hope this helps,
smtraber

NEWBIE NEEDS HELP - pull value from sql table

I have searched this forum and can't find the answer to my question. I have a login page that validates username/password. I am validating that the username is in the sql table, but I would also like to return the rest of the information for that user to pass in a querystring. For example, the user ID . I have setup my sql string to select username, password, Name, and email. How do I pull the id from this dataset?


userDataset = myUserVAlidation(enterUsername, enterPassword)
If userDataset.tables(0).rows.count = 1 then
'found record in database table
ENd if

Function myUserValidation(ByVal username as string, byVal password as string)
Dim connectionString as ...
Dim sqlConn as system.data.sqlclient.sqlconnection = new system.data.sqlClient.sqlconnection(connectionSTring)
Dim sqlString as string = "Select [userTable][username], [userTable][password], [userTable][fullName], [userTable][id] where (([userTable].[username] = @dotnet.itags.org.username) and ([userTable].[password] = @dotnet.itags.org.password))"

Dim sqlCommand as system.data.sqlclient.sqlcommand = new system.data.sqlclient.sqlCommand(sqlString, sqlConn)

sqlCommand.parameters.add("@dotnet.itags.org.username", system.data.sqldbtype.varchar).value = username
sqlCommand.parameters.add("@dotnet.itags.org.password", system.data.sqldbtype.varchar).value = password

dim dataAdapter as system.data.sqlclient.sqldataadapter = new system.data.sqlclient.sqldataadapter(sqlCommand)
dim dataset as system.data.dataset = new system.data.dataset
dataadapter.fill(dataset)
return dataset

end function

To get the id you could use the following:
string id = userDataset.Tables[0].Rows[0].ItemArray.GetValue(3)
The index for GetValue = 3 because id is the 4th column returned from your sql statement.