hi,
I am making a WCF service which is a restful service, so there is not a session maintained, as the users will be different mobile platforms like Apple , Android and symbian,
but the problem is i want to make use of windows forms authentication, i have used an OAUTH implementation for authentication purpose, but for subsequent calls my client wants me to use windowsforms authentication, and he wants the session to be closed after 12 hours, so i just made a POC (Proof Of concept) for it but its not Running,
Can any body help
Here is the Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Program user1 = new Program();
string ticket = user1.MakeTicket();
Console.WriteLine(ticket);
Console.ReadKey();
Console.WriteLine("Check the ticket");
string ticketcheck = ticket;
Console.WriteLine(user1.CheckTicket(ticketcheck).ToString());
Console.ReadKey();
}
private string MakeTicket()
{
Boolean isPersistent = true;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket("accesstoken", isPersistent, 1);
return FormsAuthentication.Encrypt(ticket);
}
private Boolean CheckTicket(string TicketToCheck)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(TicketToCheck);
if (ticket.Expired)
{
return false;
}
else
{
return true;
}
}
}
}
AND GETTING THE FOLLOWING EXCEPTION
System.Web.HttpException was unhandled by user code<br />
Message=Unable to validate data.<br />
Source=System.Web<br />
ErrorCode=-2147467259<br />
WebEventCode=0<br />
StackTrace:<br />
at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo, Boolean useLegacyMode, IVType ivType, Boolean signData)<br />
at System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)<br />
at WCFCustomAuthenticationTest.Service1.GetTicketExpiry(String Ticket) in c:\users\kundran\documents\visual studio 2010\Projects\WCFCustomAuthenticationTest\WCFCustomAuthenticationTest\Service1.svc.cs:line 46<br />
at SyncInvokeGetTicketExpiry(Object , Object[] , Object[] )<br />
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)<br />
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)<br />
InnerException:
Regards
Nakul Kundra