Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Client Application Services with Visual Studio 2008

Download

Right click “Save as…”

Author: Hi, I am Daniel Moth Smiley

Introduction: In this 18' video you will learn from scratch how to take advantage of .NET Client Application Services. As usual, the code and links to the documentation are available from my blog.

Video download: For this video, click on the image/button to play the video OR right click and Save As on the same location.

Tags:

Follow the Discussion

  • Hello, full screen video is "mirrored" - start menu on top etc.
  • Hi Karel, video appears fine here on two different machines and I've had no other complaints about this video so please try again (maybe on a different machine?).
  • Hi Daniel,

    Thanks for the great video presentation of client application services. I want to use it with Windows authentication and a custom roleprovider in a sql database. Can you change the authentication method to Windows in your sample application and can you then still access your roles if you add a user with the same name as your Windows login name (domain\username)? It does not work for me and it would prohibit me from using it which would be a shame.

    Thanks,
    Martin.
  • Martin what you are trying should work.
    Can you share more details on what problems you are encountering?
  • I would like to know how to use the Application Services for Multiple applications. If i have Application A and Application B and both  have to use the same SQl Provider.

    Do i have to have two WebServices to accomplish this or can i just use a single web service to accomplish this.

    If you have any examples I owuld greatly appreciate it.
  • William Staceystaceyw Before C# there was darkness...
    How can you prevent the client token from expiring?  I am using client app services now in test, but it keeps asking for login during Membership.ValidateUser() after some X period of time.  After my client logs in, I don't want anymore prompting until they logout or switch user. tia
  • John BaileyJBailey In an infinite universe, all things are possible
    I've been struggling with CAS for a while and was happy to see your demo.  Unfortunately your demo gives me poorer results than my own efforts. 

    I am running Vista Ultimate SP1 and Visual Studio 2008 Professional SP1.  I have .Net 3.5 sp1 installed.  SQL Server 2005 Express is at SP3.  I loaded the demo and tried to authenticate with boss666!/boss666! and got a failed authentication.  I added a user of my own using the ASP.Net manager tool just in case it was an issue with the id and password and tried it and again got a failed authentication.  I have tried it on both my laptop and desktop development machines with the same result.

    With my custom providers the authentication works, but no roles or settings are available.  When trying to access the settings it gives an error stating that you have to be authenticated to call the function.  Checking the IsAuthenticated property of the identity before hand gives a true response, but I still get the error.

    I'm not really sure what could be the issue here.  When debugging my custom providers, I see the authentication service called, but the role service it is never called.  I can't really debug your demo as there isn't any real code in the server side.

    I appear to be one of many who are having issues.  Does anyone have a clue what could be the issue or is CAS just too buggy to use in any kind of a real environment?

  • John BaileyJBailey In an infinite universe, all things are possible
    If I set the connectivity status explicitly to online ( I had originally just commented out the code where it was set to offline), the demo authenticates, but then I get the same results as in my custom providers.  I changed the load button method to the following:

    private void btnLoad_Click(object sender, EventArgs e)
    {
        if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
        {
            txtLow.Text = Settings.Default.lowValue.ToString();
            txtHigh.Text = Settings.Default.highValue.ToString();
        }
    }


    and I get the following error when I select the Load button:

    Error status code returned by the Web Service: InternalServerError. Error details from service: {"Message":"You must log on to call this method.","StackTrace":"   at System.Web.ApplicationServices.ApplicationServiceHelper.EnsureAuthenticated(HttpContext context)\r\n   at System.Web.Profile.ProfileService.GetPropertiesForCurrentUser(IEnumerable`1 properties, Boolean authenticatedUserOnly)","ExceptionType":"System.Web.HttpException"}

    Again, I'm not sure what would cause the roles and profile to fail, but it looks like these services do not think the user is logged in even though the IsAuthenticated property on the principal is true.

    Any help or suggestions would be appreciated.
  • John BaileyJBailey In an infinite universe, all things are possible
    It looks like the issue I was having was related to the automatic cookie detection at the server.  I added the following to the web.config for the web service:
      <authentication mode="Forms">
           <forms cookieless="UseCookies" />
      </authentication>

    The default is to autodetect.  Client Application Services does not work without cookies and for some reason the autodetect must be determining that cookies are not supported.  It works when I force cookie support at the server.

  • This video was great: fast paced yet complete.

    I did spend a frustrating hour or so trying to figure out why, when I checked the "Remember Me" checkbox, the next call to Membership.ValidateUser(null, null) would result in an exception:

    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="System.Web.Extensions"
      StackTrace:
           at System.Web.ClientServices.ClientFormsIdentity.GetSecureStringFromString(String password)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUserCore(String username, String password, Int32 rememberMeInt, Int32& promptCount, Boolean tryToUseLastLoggedInUser)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUserCore(String username, String password, Int32 rememberMeInt)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUser(String username, String password)
           at System.Web.Security.Membership.ValidateUser(String username, String password)
           at AppServicesClient.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\drogers\Documents\Visual Studio 2008\Projects\AppServicesDemo\AppServicesClient\Form1.cs:line 39
           at System.Windows.Forms.Form.OnLoad(EventArgs e)
           at System.Windows.Forms.Form.OnCreateControl()
           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
           at System.Windows.Forms.Control.CreateControl()
           at System.Windows.Forms.Control.WmShowWindow(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.ContainerControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WmShowWindow(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at AppServicesClient.Program.Main() in C:\Users\drogers\Documents\Visual Studio 2008\Projects\AppServicesDemo\AppServicesClient\Program.cs:line 18
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    I found that by replacing the null arguments with string.empty, (Membership.ValidateUser(string.Empty, string.Empty)) the program worked as expected.

    Thanks again and ciao,
    David
  • Daniel,

     

    How do you deploy the above described service to the IIS?

     

    Thanks,

     

    Marat

  • Marat MusaevMarat Marat

    Daniel,

     

    What is the proper way to deploy the above service to IIS?

     

    Marat

  • EdgardEdgard

    Hi everybody, im trying to implement this, but when i used de aplication in other machine i get the next message:
    Se ha producido un error al crear el controlador de seccion de configuracion para system.web/membership
     
    some idea how solve it?

  • TobeTobe

    @Daniel or anyone
    You implemented service and client as two different applications. Is there a way I can implement both in one visual studio solution and deploy as a whole and not as different applications.
    Thank you

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.