Access Control to a WebService in .NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SpeedJunkie
    New Member
    • Mar 2009
    • 12

    Access Control to a WebService in .NET

    Hi,
    I have a windows application and I am using a webservice in that. Now I want that this webservice should be only accessible through my application and if user tries to access the webservice by typing the URL in a browser he should not be able to see the methods.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    That seems like a reasonable 'want'

    Comment

    • SpeedJunkie
      New Member
      • Mar 2009
      • 12

      #3
      Any body has any ideas how to achieve this.....

      Comment

      • PRR
        Recognized Expert Contributor
        • Dec 2007
        • 750

        #4
        Try this : Pass Current Credentials to an ASP.NET Web Service

        Comment

        • SpeedJunkie
          New Member
          • Mar 2009
          • 12

          #5
          Thnx for your reply DeepBlue
          I am calling the Webservice from the winform application.

          I have checked the Integrated Windows Auth in IIS server and unchecked Anonymous access.
          Here is sample code for what i am trying to do.
          Code:
          Webservice temp = new Webservice();
                      WebProxy proxy = new WebProxy(temp.Url,false);
                      temp.Proxy = proxy;
                      temp.Proxy.Credentials = CredentialCache.DefaultCredentials;
                      temp.HelloWorld();
          But still I am getting 401 error. Also I noticed that DefaultCredenti als don't have empty strings in user name, password and domain name.
          Any ideas why this is happening?
          Last edited by Frinavale; May 7 '09, 03:01 PM. Reason: Added code tags. Please post code in [code] [/code] tags.

          Comment

          • PRR
            Recognized Expert Contributor
            • Dec 2007
            • 750

            #6
            If you are talking about adding web service reference to the windows application, its the same way as in asp.net application... Add web reference ...

            Comment

            • SpeedJunkie
              New Member
              • Mar 2009
              • 12

              #7
              I have checked the Integrated Windows Auth in IIS server and unchecked Anonymous access.
              Here is sample code for what i am trying to do.

              Code:
              Webservice temp = new Webservice();
              WebProxy proxy = new WebProxy(temp.Url,false);
              temp.Proxy = proxy;
              temp.Proxy.Credentials = CredentialCache.DefaultCredentials;
              temp.HelloWorld();
              But still I am getting 401 error. Also I noticed that DefaultCredenti als don't have empty strings in user name, password and domain name.
              Any ideas why this is happening?
              Last edited by Frinavale; May 7 '09, 03:01 PM. Reason: Added code tags. Please post code in [code] [/code] tags.

              Comment

              • SpeedJunkie
                New Member
                • Mar 2009
                • 12

                #8
                Any ideas guys........

                Comment

                • balame2004
                  New Member
                  • Mar 2008
                  • 142

                  #9
                  Compile the method as internal in web service so that would be invisible when you type url in browser.
                  Code:
                    [WebMethod]
                         internal string HelloWorld()
                          {
                              return "Hello World";
                          }
                  Last edited by Frinavale; May 11 '09, 03:00 PM. Reason: Added code tags. Please post code in [code] [/code] tags.

                  Comment

                  Working...