c# - authentication before creation of database item -


hi have problem authentication , creation of database item. in documentation says authentication should called before creation. here code have done , wonder if have events in wrong order.

private void applicationbariconbutton_click_5(object sender, eventargs e)     {         gateway.authenticateasync("username", "password1", "username2", "password2");         gateway.authenticatecompleted += new eventhandler<servicereference.authenticatecompletedeventargs>(authenticatetime);         }      private datetime _nesteddatestart;     private datetime _nesteddateend;     private datetime _nesteddatestartbreak1;     private datetime _nesteddateendbreak1;     private datetime _nesteddatestartbreak2;     private datetime _nesteddateendbreak2;      servicereference.timereportdto timereport = new servicereference.timereportdto();      void authenticatetime(object sender, servicereference.authenticatecompletedeventargs e)     {          gateway.authenticateasync("username1", "password1", "username2", "password2");               timereport.started = _nesteddatestart;         timereport.ended = _nesteddateend;          timereport.break1start = _nesteddatestartbreak1;         timereport.break1end = _nesteddateendbreak1;          timereport.break2start = _nesteddatestartbreak2;         timereport.break2end = _nesteddateendbreak2;          timereport.comment = notes.text;         timereport.employeesignature = "apptest";          gateway.createtimereportasync(timereport,"abd");         gateway.createtimereportcompleted += new eventhandler<servicereference.createtimereportcompletedeventargs>(createtimereportcompleted);      }      void createtimereportcompleted(object sender, servicereference.createtimereportcompletedeventargs e)     {      } 

when set breakpoint on "createtimereportcompleted" error shown below in image:

enter image description here

as can see returns message "access denied,please login first". becaus usernames , passwords correct figure must have code in wrong order or something.

update

gateway servicereference looks this:

servicereference.gatewaysoapclient gateway = new servicereference.gatewaysoapclient(); 

and if authentication cookie supposed passed next service call dont know. nothing saying in documentation.

they have in documentation below authentication cookiecontainer isnt when make webbrowser?

anyone can me?

method 1:- (without forcefully passing cookies through code)

in asmx web config add aspnetcompatibilityenabled="true" , set allowcookies=false

in servicereferences.clientconfig add allowcookiecontainer=true

method 2:- (passing cookies around via code)

in asmx web config set allowcookies=true in servicereferences.clientconfig add allowcookiecontainer=true , can set

client.cookiecontainer=yourcookiecontainervariable

and pass along 'yourcookiecontainervariable' next service call.

this method particularly useful when have separate url authenticationa nd other business functions

as depicted in : http://www.kotancode.com/2010/08/06/aspnet-authentication-wp7/


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -