Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:27:46+00:00 2026-06-07T10:27:46+00:00

I have created simple .NET Web Service (ASMX) that I call from my .NET

  • 0

I have created simple .NET Web Service (ASMX) that I call from my .NET web application. The service and web app both use Windows Authetication.

com.mydomain.MyWebService webSrvc = new com.mydomain.MyWebService();
string output = webSrvc.MyServiceMethod();

I am now creating Windows app with C#, and would like to call the same web service from there. I have added a web reference in my project to the service, and I can make calls to the service web methods without issue. The problem is, inside the web methods, I am trying to retrieve the user’s windows user name.

string username = User.Identity.Name; //always blank

This works when I call the web service from my web app, but when I call it from my windows app, it always returns blank, and User.Identity.IsAuthenticated is always false, if that is relevant. What am I missing here. I just need to get the Windows user username that is running the console app, that called the web service. I have tried setting the credentials of webSrvc to the ClientCache default credentials, but that doesn’t solve the problem.

UPDATE: I don’t know if this is useful, but I learned that if I use Environment.UserName, it will give “NETWORK_SERVICE”, and then if i enable impersonation, it will give “IUSR_[host_name]”. It seems like i’m just missing something really simple. I just want to get the current windows user, who is running the windows app (which calls the web service).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:27:48+00:00Added an answer on June 7, 2026 at 10:27 am

    Are you passing network credentials to your web service object before calling it? Something like:

    NetworkCredential credentials = new
    NetworkCredential(UserName,SecurelyStroredPassword,Domain);
    
    // Add the NetworkCredential to the CredentialCache.
    credentialCache.Add(new Uri(webSrvc.Url), 
                       "Basic", credentials);
    

    Cribbed from: http://msdn.microsoft.com/en-us/library/bfazk0tb.aspx

    Basically when the web service is called from the web app you already have all the cookie and session info sticking around. When you write a standalone application it won’t have access to the cookies, form data, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have created a very simple asp.net web service using .NET framework 3.5,
I have a very simple ASP.NET web application created under Visual Studio 2008 (SP1),
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have wrote a basic web service using .net which I intend to use
I have a simple ajax request that I am trying to call a web
I have two applications Web Socket and Web Service created in .Net/Web Form and
Could someone help me on this, I have created simple web services using axis2
The old ASP.NET ASMX Web services used to produce a Web page that allowed
I have a ASP.NET 1.1 application running on IIS 6 / Windows Server 2003.
I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.