Client Application Services with Visual Studio 2008
- Posted: Feb 23, 2008 at 2:09 PM
- 17,041 Views
- 14 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Author: Hi, I am Daniel Moth ![]()
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.
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.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
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.
Can you share more details on what problems you are encountering?
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.
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?
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.
<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.
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
Daniel,
What is the proper way to deploy the above service to IIS?
Marat
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?
@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