Hi Chuck,
Thanks for your response.
The code should be as follow
===========================
//MachineKeySection m = new MachineKeySection();
//m.DecryptionKey = "your decryptionKey";
Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("~");
MachineKeySection m=
(MachineKeySection)configuration.GetSectionGroup("system.web").Sections["mac
hineKey"];
m.DecryptionKey = "your decryptionKey";
===========================
The FormsAuthentication.Encrypt method internally uses the specified in
web.config. As far as I know, we cannot change it to read value from
another file instead of the configuration in web.config. This is by design.
To test ASP.NET web application, you can also consider using Visual Studio
Team System. For the introduce, you can refer to
http://www.asp.net/Learn/vsts-videos/video-128.aspx
I look forward to receiving your test results.
--
Best Regards,
Thomas Sun
Microsoft Online Partner Support
--------------------
|
| I'm pretty sure that won't work because the MachineKeySection m never
gets
| used by anything.
|
| You don't really need selenium any C# class that runs without access to
the
| HttpContext will do.
|
|
| "Thomas Sun [MSFT]" wrote:
|
| > Hi Chuck,
| >
| > The FormsAuthentication.Encrypt method internally uses the algorithm
and
| > key specified by the decryption and decryptionKey attributes on the
| > machineKey element of your web.config.
| >
| > I am not using Selenium. If it cannot access web.config, you can try to
set
| > decryptionKey property programmatically.
| > For example:
| > =====================================
| >
| > MachineKeySection m = new MachineKeySection();
| > m.DecryptionKey = "your decryptionKey";
| >
| > FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(1,
| > "userName",
| > DateTime.Now,
| > DateTime.Now.AddMinutes(20),
| > false,
| > String.Empty,
| > FormsAuthentication.FormsCookiePath);
| >
| > string encryptedTicket = FormsAuthentication.Encrypt(ticket);
| >
| > =====================================
| >
| > For more information about MachineKeySection.DecryptionKey Property,
See
| >
http://msdn.microsoft.com/en-us/library/system.web.configuration.machinekeys
| > ection.decryptionkey.aspx
| >
| >
| >
| > I look forward to receiving your test results.
| >
| >
| > Best Regards,
| > Thomas Sun
| >
| > Microsoft Online Partner Support
| >
| > ==================================================
| > Get notification to my posts through email? Please refer to
| >
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
| > ications.
| >
| > With newsgroups, MSDN subscribers enjoy unlimited, free support as
opposed
| > to the limited number of phone-based technical support incidents.
Complex
| > issues or server-down situations are not recommended for the
newsgroups.
| > Issues of this nature are best handled working with a Microsoft Support
| > Engineer using one of your phone-based incidents.
| > ==================================================
| >
| > This posting is provided "AS IS" with no warranties, and confers no
rights.
| >
| > --------------------
| > |
| > | I'm using Selenium to test a web application.
| > | I need to create a Forms Authentication Cookie and let Selenium load
it
| > into
| > | the browser instance.
| > |
| > | I'm having a problem because my nUnit class does not have access to
the
| > | web.config file.
| > | The website uses MachineKey valdationKey and decryptionKey.
| > | I know these values and can put them in the nUnit class.
| > | However, I usually create Forms Cookies by doing
| > |
| > | tkt = new FormsAuthenticationTicket(1, txtNewIdentity.Text,
| > DateTime.Now,
| > | DateTime.Now.AddMinutes(TimeOut_Get()),
bPersistent,
| > | HttpContext.Current.Request.UserHostAddress);
| > |
| > | CookieValue= FormsAuthentication.Encrypt(tkt)
| > |
| > | I don't believe the cookie will properly encrypted because when I run
| > | .Encrypt(tkt), it won't find the encryption key to use.
| > |
| > | Any way to manually make the forms authentication cookie without
assuming
| > | the .net methods have access to the web.config file?
| > |
| > |
| > |
| > |
| >
| > .
| >
|