-1

I've built a small App that register a service that looks like an Airpint to IOS device. I have little knowledge on IPP programming. I am using Monozeroconf Dll and C# to register my service etc... and that's all work fine but i would like to display a popup to enter Username and password so that i can identify the person that is printing.

Can someone help or point me to the right direction.

Thanks in advance.

  • Please elaborate on what you have tried and show that actual code snippet. – Roi Danton Jul 16 '18 at 13:45
  • Below is the code am using to do the GET request: HttpWebRequest request = WebRequest.Create("url") as HttpWebRequest; request.Credentials = new NetworkCredential(loginUserName, password); WebResponse response = request.GetResponse(); from my understanding after sending the GERT Request the resoource should see that an authentication is needed and should show me a popup on the IOS device requiring an authentication. not sure if this logic is right. – user9752057 Jul 17 '18 at 07:28

1 Answers1

0

Just in case someone out there has been struggling with this, here's my code

 if (!HttpListener.IsSupported)
    {
        Console.WriteLine("Server does not support Http Listener.");
        return;
    }
    // URI prefixes required,
    if (prefixes == null || prefixes.Length == 0)
        throw new ArgumentException("prefixes required");

    // Create a listener.
    HttpListener listener = new HttpListener();
    // Add the prefixes.
    foreach (string s in prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    listener.AuthenticationSchemes = AuthenticationSchemes.Basic;
    Console.WriteLine("About to listen to " + prefixes[0].ToString());

    if (listener.IsListening) {
        Console.WriteLine("Currently Listening to " + prefixes[0].ToString());
    }
    //Wait until a connection is made before continuing
    //allDone.WaitOne();

    // Note: The GetContext method blocks while waiting for a request.
    HttpListenerContext context = listener.GetContext();

    //Retrives Username and password from the Http Request
    var hlbi = (HttpListenerBasicIdentity)context.User.Identity;
    Console.WriteLine("Username: " + hlbi.Name);
    Console.WriteLine("Password: " + hlbi.Password);

    listener.Stop();`

for some reason my firewall was blocking connection on Getcontext(), so i had to put an excpetion on the IPP port 631.(not the application)