Thanks in advance for help on the following two items.
(1) I have a custom CreateUserWizard that accepts my phony testing data (for example, "m" for each textbox field), but when I enter "real" data, I get a server error page with this message:
Security Exception
Description:
The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Any clues on why it won't accept real data? I haven't change any permissions settings nor do I know how to.
(2) I use the following code in my wizard and it works great (with the phony data, that is):
I want to get at least one of these values so that I can query for the primary key (an auto-generated integer) and pass it as a query string for a wizard on the next page. (The next page asks for additional signup data from the user. I tried to do this as
an extra step in the first wizard, but it didn't work out very well so I decided to try it in an extra page.) Naturally (you guessed the question), I need to know a way to get at least one of these values. Any suggestions?
By the way, I'm trying to do this within the ContinueButton_Click procedure, after the user is created but before it goes to the next page. My guess is that it returns a null value because by the time you click on the button, the wizard is
"over and done with." Regardless, there must be a way to retrieve user information since the same user is still using the application and is logged in. Would it be better to retrieve login information? Would this be done in ContinueButton_Click? Also, what
would the code look like?
Regardless,
there must be a way to retrieve user information since the same user is still using the application and is logged in. Would it be better to retrieve login information? Would this be done in ContinueButton_Click? Also, what would the code look like?
Hi
Here is some information for the 2# question
If you want to retrieve the UserID of the currently logged in user, please use the following code:
MembershipUser user = Membership.GetUser();
if (user != null)
{
Guid userId = new Guid(user.ProviderUserKey.ToString());
}
Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Dim objUser
As MembershipUser = Membership.GetUser()
If Not IsNothing(objUser) Then
Dim objUserID As Guid = New Guid(objUser.ProviderUserKey.ToString()) End If
Response.Redirect("~/reg2.aspx?strUID=" & objUserID)
...but when I use it per the above, it gets a squiggly blue error underline. I also tried to make it equal to a string...
string stmt =
"select count(*) " +
"from Users " +
"where (UserID= @UserID or username = @username ) " +
" and cast(password as varbinary(255)) " +
" = cast(@password as varbinary(255)) ";
SqlCommand cmd = new SqlCommand(stmt, conn);
cmd.Parameters.Add("@UserID", SqlDbType.VarChar, 100);
cmd.Parameters["@UserID"].Value =strUserID.Trim();
Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
An added bonus is the discovery that I don't have to pass the query string after all. With the useful code you supplied, I found that I was able to pick up the user name and ID on the second page also, which is a great help so I didn't need to pass it as
a query string. Now I don't have to go through all the extra effort I was going to do to encrypt the query string. Thanks again.
muybn
Participant
853 Points
1290 Posts
(1) wizard error with "real" data; (2) need to pass query string parameter
Jan 18, 2008 08:44 AM|LINK
Thanks in advance for help on the following two items.
(1) I have a custom CreateUserWizard that accepts my phony testing data (for example, "m" for each textbox field), but when I enter "real" data, I get a server error page with this message:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Any clues on why it won't accept real data? I haven't change any permissions settings nor do I know how to.
(2) I use the following code in my wizard and it works great (with the phony data, that is):
I want to get at least one of these values so that I can query for the primary key (an auto-generated integer) and pass it as a query string for a wizard on the next page. (The next page asks for additional signup data from the user. I tried to do this as an extra step in the first wizard, but it didn't work out very well so I decided to try it in an extra page.) Naturally (you guessed the question), I need to know a way to get at least one of these values. Any suggestions?
By the way, I'm trying to do this within the ContinueButton_Click procedure, after the user is created but before it goes to the next page. My guess is that it returns a null value because by the time you click on the button, the wizard is "over and done with." Regardless, there must be a way to retrieve user information since the same user is still using the application and is logged in. Would it be better to retrieve login information? Would this be done in ContinueButton_Click? Also, what would the code look like?
muybn
Participant
853 Points
1290 Posts
Re: (1) wizard error with "real" data; (2) need to pass query string parameter
Jan 20, 2008 05:55 AM|LINK
I seem to have resolved the first problem above by changing the Trust Level to "Full" in web.config:
<
trust level="Full"/>It still puzzles me as to why the application would accept one set of input and not another.
I'm still waiting for help on #2 above.....
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: (1) wizard error with "real" data; (2) need to pass query string parameter
Jan 22, 2008 06:54 AM|LINK
Hi
Here is some information for the 2# question
If you want to retrieve the UserID of the currently logged in user, please use the following code:
MembershipUser user = Membership.GetUser();
if (user != null)
{
Guid userId = new Guid(user.ProviderUserKey.ToString());
}
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
muybn
Participant
853 Points
1290 Posts
Re: (1) wizard error with "real" data; (2) need to pass query string parameter
Jan 23, 2008 04:01 AM|LINK
Thanks, Dai, I get a value from objUserID...
Dim objUser As MembershipUser = Membership.GetUser()
...but that didn't work either. How do I use that value for the querystring I'm trying to create?If Not IsNothing(objUser) Then
Dim objUserID As Guid = New Guid(objUser.ProviderUserKey.ToString())
End If
Response.Redirect("~/reg2.aspx?strUID=" & objUserID)
...but when I use it per the above, it gets a squiggly blue error underline. I also tried to make it equal to a string...
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: (1) wizard error with "real" data; (2) need to pass query string parameter
Jan 24, 2008 01:33 AM|LINK
Well, You can try this code:
strUserID = objUser.ProviderUserKey.ToString();
string stmt =
"select count(*) " +
"from Users " +
"where (UserID= @UserID or username = @username ) " +
" and cast(password as varbinary(255)) " +
" = cast(@password as varbinary(255)) ";
SqlCommand cmd = new SqlCommand(stmt, conn);
cmd.Parameters.Add("@UserID", SqlDbType.VarChar, 100);
cmd.Parameters["@UserID"].Value =strUserID.Trim();
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
muybn
Participant
853 Points
1290 Posts
Re: (1) wizard error with "real" data; (2) need to pass query string parameter
Jan 24, 2008 05:30 AM|LINK
Perfect! Thank you very much!
An added bonus is the discovery that I don't have to pass the query string after all. With the useful code you supplied, I found that I was able to pick up the user name and ID on the second page also, which is a great help so I didn't need to pass it as a query string. Now I don't have to go through all the extra effort I was going to do to encrypt the query string. Thanks again.