Click here to Skip to main content
15,907,905 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionAPI call from VB.net Pin
hribek2514-Dec-08 21:37
hribek2514-Dec-08 21:37 
AnswerRe: API call from VB.net Pin
Ben Fair15-Dec-08 2:02
Ben Fair15-Dec-08 2:02 
AnswerRe: API call from VB.net Pin
Thomas Stockwell17-Dec-08 5:39
professionalThomas Stockwell17-Dec-08 5:39 
QuestionConvert HTML into RTF Pin
JR21214-Dec-08 21:22
JR21214-Dec-08 21:22 
AnswerRe: Convert HTML into RTF Pin
Christian Graus14-Dec-08 21:49
protectorChristian Graus14-Dec-08 21:49 
GeneralRe: Convert HTML into RTF Pin
JR21214-Dec-08 23:11
JR21214-Dec-08 23:11 
GeneralRe: Convert HTML into RTF Pin
Dave Kreskowiak15-Dec-08 4:20
mveDave Kreskowiak15-Dec-08 4:20 
QuestionCalling webservice with forms authentication Pin
AlexeiXX314-Dec-08 16:25
AlexeiXX314-Dec-08 16:25 
Hi, thanks for looking
Im having a little problem here

I have a website, in this website i have a webservice with a few webmethods, i dont want anyone calling these methods unless the have permisions (In fact, im calling them from a win app)

In my site im using forms authentication
So, before calling any webmethod i call the SignIn Method

I am currently using the first method because the second one doesnt work when called from win app
I dont know why, i saw examples that stated that it works as well

Method that works either when called from win app or with my browser
<WebMethod()> _
Public Function SignIn(ByVal Nick As String, ByVal Password As String) As Boolean
    If Not Membership.ValidateUser(Nick, Password) Then Return False

    Dim ticket As New FormsAuthenticationTicket(1, Nick, Now, Now.AddYears(1), True, "")
    Dim strEncryptedTicket As String = FormsAuthentication.Encrypt(ticket)
    Dim cookie As New HttpCookie(FormsAuthentication.FormsCookieName, strEncryptedTicket)
    Context.Response.Cookies.Add(cookie)
    Return True
End Function

Method that only works when i use it with my browser
<WebMethod()> _
Public Function SignIn(ByVal Nick As String, ByVal Password As String) As Boolean
    If Not Membership.ValidateUser(Nick, Password) Then Return False

    FormsAuthentication.SetAuthCookie(Nick, True)
    Return True
End Function

Example of method that i can call only after ive called the SignIn method (with true as result)
<WebMethod()> _
Public Function HelloWorld() As String
    If Not User.Identity.IsAuthenticated Then Return ""

    Return "Hello World"
End Function


In my win app i am using the cookiecontainer
As i told you, it works with the first singin method but not with the second


I used this page as a reference:
http://blog.webgear.co.nz/archive/2007/11/23/forms-authentication-in-web-services.aspx[^]


Im not quite sure, but i think that since i added this webservice, ive started to receive the following error (This error is causing all autenthicated users (Users of the web portal as well as users of the webservice) to be logout and have to log in again):

System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo)
at System.Web.UI.Page.DecryptString(String s)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thanks in advance for any feedback

Alexei Rodriguez

Questionsend email Pin
angels77714-Dec-08 2:33
angels77714-Dec-08 2:33 
AnswerRe: send email Pin
Colin Angus Mackay14-Dec-08 4:20
Colin Angus Mackay14-Dec-08 4:20 
AnswerRe: send email Pin
LloydA11114-Dec-08 6:55
LloydA11114-Dec-08 6:55 
AnswerRe: send email Pin
Christian Graus14-Dec-08 8:29
protectorChristian Graus14-Dec-08 8:29 
GeneralRe: send email Pin
astanton197815-Dec-08 8:08
astanton197815-Dec-08 8:08 
Questionsend email Pin
angels77714-Dec-08 2:19
angels77714-Dec-08 2:19 
AnswerRe: send email Pin
Christian Graus14-Dec-08 8:29
protectorChristian Graus14-Dec-08 8:29 
AnswerRe: send email Pin
Charl14-Dec-08 20:57
Charl14-Dec-08 20:57 
QuestionEnable/Disable Modem Pin
Member 216783614-Dec-08 1:53
Member 216783614-Dec-08 1:53 
Question[Message Deleted] Pin
njote13-Dec-08 19:36
njote13-Dec-08 19:36 
AnswerRe: help me Pin
Christian Graus13-Dec-08 22:30
protectorChristian Graus13-Dec-08 22:30 
QuestionHow to open an existing excel spreadsheet using vb.net Pin
samsonx12-Dec-08 22:15
samsonx12-Dec-08 22:15 
AnswerRe: How to open an existing excel spreadsheet using vb.net Pin
Mycroft Holmes12-Dec-08 22:47
professionalMycroft Holmes12-Dec-08 22:47 
AnswerRe: How to open an existing excel spreadsheet using vb.net Pin
Dave Kreskowiak13-Dec-08 6:04
mveDave Kreskowiak13-Dec-08 6:04 
AnswerRe: How to open an existing excel spreadsheet using vb.net Pin
LloydA11113-Dec-08 7:38
LloydA11113-Dec-08 7:38 
QuestionUSB Hardware Locker Pin
JC.KaNNaN12-Dec-08 22:12
JC.KaNNaN12-Dec-08 22:12 
AnswerRe: USB Hardware Locker Pin
Dave Kreskowiak13-Dec-08 6:03
mveDave Kreskowiak13-Dec-08 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.