Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > How To Add User's GUID To An Account Verification E-mail

Reply
Thread Tools

How To Add User's GUID To An Account Verification E-mail

 
 
Jonathan Gill
Guest
Posts: n/a
 
      10-28-2007
Hi everyone,
So I have a problem that is more difficult that it might seem at first
glance. created. Any help/a clever "duh" answer would be great as we've
spent more than 8 hours trying to get this working.

Please see the following thread for the full details:

"How To Add User's GUID To An Account Verification E-mail - E-mail Working,
Error In Retreiving GUID"

http://forums.asp.net/p/1172523

----
am receiving an error when I try to retrieve a newly (and
successfully...checked the DB) registered users GUID to include in an account
verification e-mail. I am using the e-mail that is sent by the membership
provider, however I am adding an extra step for the user to verify their
account. The e-mail works fine as long as I don't try and use the user's
GUID. The verification of a user's account step uses a newly defined
placeholder (<% Username %> and <% Password %> are supported by default in
asp.net membership) in the .txt file that is the basis for the e-mail. I can
get the placeholder to replace fine in the e-mail, however I get an error
when I try to include the user's GUID in the e-mail.

Here are examples:
http://www.pcw.co.uk/personal-comput...p-rules?page=3,
http://dotnetjunkies.com/WebLog/sara...30/137645.aspx

Any help with fixing the error is appreciated. Thanks!



Error

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_Web_rih02pg9"
StackTrace:
at signup.CreateUserWizard1_SendingMail(Object sender,
MailMessageEventArgs e) in C:\Documents and Settings\Owner\My
Documents\Visual Studio 2005\WebSites\Test\Signup.aspx.vb:line 81
at
System.Web.UI.WebControls.CreateUserWizard.OnSendi ngMail(MailMessageEventArgs
e)
at System.Web.UI.WebControls.LoginUtil.SendPasswordMa il(String email,
String userName, String password, MailDefinition mailDefinition, String
defaultSubject, String defaultBody, OnSendingMailDelegate
onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
Control owner)


Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
CreateUserWizard1.SendingMail
Dim tempMem As MembershipUser =
Membership.GetUser(CreateUserWizard1.UserName)

'Replace placeholder for the verification URL
e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=" &
tempMem.ProviderUserKey.ToString) ' Error occurs on this line
'Line below will work and replace the placeholder in the e-mail file
'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=123)

End Sub Protected Sub CreateUserWizard1_SendingMail(ByVal sender As
Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
CreateUserWizard1.SendingMail
Dim tempMem As MembershipUser =
Membership.GetUser(CreateUserWizard1.UserName.ToSt ring)
MsgBox(tempMem.ProviderUserKey.ToString) ' Will return error here

'Replace placeholder for the verification URL
e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=" &
tempMem.ProviderUserKey.ToString) ' Error occurs on this line
'Line below will work and replace the placeholder in the e-mail file

'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=123)
End Sub
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      10-28-2007
On Oct 28, 2:37 am, Jonathan Gill
<JonathanG...@discussions.microsoft.com> wrote:
> http://forums.asp.net/p/1172523


Link doesn't work


> System.NullReferenceException was unhandled by user code
> Message="Object reference not set to an instance of an object."


It means your GUID is null, try to check it before making a call.

 
Reply With Quote
 
 
 
 
Jonathan Gill
Guest
Posts: n/a
 
      10-28-2007
Yes, Membership.Getuser says the user is null, but it is not. If I set a
break point before I call Membership.GetUser in the CreatedUser event of the
CreateNewUserWizard or even inthe SendingMil event which fires after
CreatedUser then I can manully check the DB and see all of the user's details
saved.

"Alexey Smirnov" wrote:

> On Oct 28, 2:37 am, Jonathan Gill
> <JonathanG...@discussions.microsoft.com> wrote:
> > http://forums.asp.net/p/1172523

>
> Link doesn't work
>
>
> > System.NullReferenceException was unhandled by user code
> > Message="Object reference not set to an instance of an object."

>
> It means your GUID is null, try to check it before making a call.
>
>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      10-29-2007
On Oct 28, 5:09 pm, Jonathan Gill
<JonathanG...@discussions.microsoft.com> wrote:
> Yes, Membership.Getuser says the user is null, but it is not. If I set a
> break point before I call Membership.GetUser in the CreatedUser event of the
> CreateNewUserWizard or even inthe SendingMil event which fires after
> CreatedUser then I can manully check the DB and see all of the user's details
> saved.
>
>
>
> "Alexey Smirnov" wrote:
> > On Oct 28, 2:37 am, Jonathan Gill
> > <JonathanG...@discussions.microsoft.com> wrote:
> > >http://forums.asp.net/p/1172523

>
> > Link doesn't work

>
> > > System.NullReferenceException was unhandled by user code
> > > Message="Object reference not set to an instance of an object."

>
> > It means your GUID is null, try to check it before making a call.- Hide quoted text -

>
> - Show quoted text -


What line is #81?

 
Reply With Quote
 
Jonathan Gill
Guest
Posts: n/a
 
      10-29-2007
Finally, determined the cause of the error. The DB had two application IDs
while I specified the applicationName in the membership provider, I needed to
specify the applicationName that I was looking for users in.



"Jonathan Gill" wrote:

> Hi everyone,
> So I have a problem that is more difficult that it might seem at first
> glance. created. Any help/a clever "duh" answer would be great as we've
> spent more than 8 hours trying to get this working.
>
> Please see the following thread for the full details:
>
> "How To Add User's GUID To An Account Verification E-mail - E-mail Working,
> Error In Retreiving GUID"
>
> http://forums.asp.net/p/1172523
>
> ----
> am receiving an error when I try to retrieve a newly (and
> successfully...checked the DB) registered users GUID to include in an account
> verification e-mail. I am using the e-mail that is sent by the membership
> provider, however I am adding an extra step for the user to verify their
> account. The e-mail works fine as long as I don't try and use the user's
> GUID. The verification of a user's account step uses a newly defined
> placeholder (<% Username %> and <% Password %> are supported by default in
> asp.net membership) in the .txt file that is the basis for the e-mail. I can
> get the placeholder to replace fine in the e-mail, however I get an error
> when I try to include the user's GUID in the e-mail.
>
> Here are examples:
> http://www.pcw.co.uk/personal-comput...p-rules?page=3,
> http://dotnetjunkies.com/WebLog/sara...30/137645.aspx
>
> Any help with fixing the error is appreciated. Thanks!
>
>
>
> Error
>
> System.NullReferenceException was unhandled by user code
> Message="Object reference not set to an instance of an object."
> Source="App_Web_rih02pg9"
> StackTrace:
> at signup.CreateUserWizard1_SendingMail(Object sender,
> MailMessageEventArgs e) in C:\Documents and Settings\Owner\My
> Documents\Visual Studio 2005\WebSites\Test\Signup.aspx.vb:line 81
> at
> System.Web.UI.WebControls.CreateUserWizard.OnSendi ngMail(MailMessageEventArgs
> e)
> at System.Web.UI.WebControls.LoginUtil.SendPasswordMa il(String email,
> String userName, String password, MailDefinition mailDefinition, String
> defaultSubject, String defaultBody, OnSendingMailDelegate
> onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
> Control owner)
>
>
> Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object,
> ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
> CreateUserWizard1.SendingMail
> Dim tempMem As MembershipUser =
> Membership.GetUser(CreateUserWizard1.UserName)
>
> 'Replace placeholder for the verification URL
> e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
> "http://www.test.com/VerifyAccount.aspx?key=" &
> tempMem.ProviderUserKey.ToString) ' Error occurs on this line
> 'Line below will work and replace the placeholder in the e-mail file
> 'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
> "http://www.test.com/VerifyAccount.aspx?key=123)
>
> End Sub Protected Sub CreateUserWizard1_SendingMail(ByVal sender As
> Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
> CreateUserWizard1.SendingMail
> Dim tempMem As MembershipUser =
> Membership.GetUser(CreateUserWizard1.UserName.ToSt ring)
> MsgBox(tempMem.ProviderUserKey.ToString) ' Will return error here
>
> 'Replace placeholder for the verification URL
> e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
> "http://www.test.com/VerifyAccount.aspx?key=" &
> tempMem.ProviderUserKey.ToString) ' Error occurs on this line
> 'Line below will work and replace the placeholder in the e-mail file
>
> 'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
> "http://www.test.com/VerifyAccount.aspx?key=123)
> End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Google Add URL Verification code Broken n3td3v Computer Security 0 12-29-2009 10:53 PM
How could I use NTL account to work with Freeserve account? Rajinder Nijjhar Computer Support 5 03-21-2006 07:39 PM
Converting AIM Account 2 AOL Account? Computer Support 7 08-28-2004 12:14 AM
Q: Disconnected DataSets - automatic Add/Remove but with Guid Key instead of AutoIncrement int? Sky ASP .Net 2 01-30-2004 09:22 PM



Advertisments