Help in converting the php code

Last post 08-29-2007 2:05 AM by fazal.shaikh. 3 replies.

Sort Posts:

  • Help in converting the php code

    07-27-2007, 12:36 AM
    • Member
      50 point Member
    • fazal.shaikh
    • Member since 06-18-2007, 1:41 AM
    • Posts 40

    Hello all,

    I am having a problem in converting the following code  into asp.net.

    $lines = file("http://someIPAddress/login/chkauth.asp?login=$username&pwd=$password");
    $filestr="";
    foreach ($lines as $line_num => $line) {
      $filestr=$filestr.htmlspecialchars($line);
    }
    $loginverify=0;
    $loginverify=preg_match("/Invalid/",$filestr);
    //preg_match is similar to the substr or instr function of string object.
    //above LOC is finding "Invalid" within $filestr variable.

    the above code is used for using the output generated by the page chkauth.asp.

    I was able to make out the last method i.e. preg_match(). but help me with the file() method.

    thanks

     Fazal
     

  • Re: Help in converting the php code

    07-27-2007, 2:00 AM
    • Participant
      1,674 point Participant
    • somnathmali
    • Member since 07-16-2007, 8:09 AM
    • Pune , INDIA
    • Posts 257

    Use WebRequest Class...

    using System.IO;
    using System.Net;

      WebRequest request = WebRequest.Create ("http://.... ");

    for details please check http://msdn2.microsoft.com/en-us/library/debx8sh9.aspx

     

    Somnath Mali
    .NET Developer , Pune INDIA.






    Please Mark As Answer If my reply helped you.

  • Re: Help in converting the php code

    07-27-2007, 5:31 AM
    Answer
    • Member
      50 point Member
    • fazal.shaikh
    • Member since 06-18-2007, 1:41 AM
    • Posts 40

    thanks somnath,

    but your link to the page helped me in urls without  querystrings. If I am passing any querystring parameter, then it gives an error saying "Cannot send a content-body with this verb-type." But the other link I got from somewhere else, helped me. the code is.

                    strURL = "http://someIPAddress/login/chkauth.asp?login=userName&pwd=password
                    Dim objClient As New WebClient
                    objLines = objClient.OpenRead(strURL)
                    Dim objStreamReader As New StreamReader(objLines)
                    strLines = objStreamReader.ReadToEnd

    http://msdn2.microsoft.com/en-us/library/bay1b5dh.aspx

     

    Thanks a lot. 

    Fazal... 

  • Re: Help in converting the php code

    08-29-2007, 2:05 AM
    • Member
      50 point Member
    • fazal.shaikh
    • Member since 06-18-2007, 1:41 AM
    • Posts 40

    Hello all,

    After implementing the previous code that I had used, I am facing a typical problem.

    On the VS.NET I am able to run the application successfully.

    When I run it on the Local server (localhost) it is giving me the following error

    "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"

    and when I am running it on the same machine but with IP address of the system or from the client machine, it is giving me same error.

    can anyone help me out of this...

     

    Thanks in Advance... 

Page 1 of 1 (4 items)