Accessing an ISAPI Ext. through an ASP.NET Web Service

Discussion in 'ASP .Net Web Services' started by Gabby Shainer, Nov 4, 2003.

  1. Hello,

    I have an ASP.NET Web Service written in C# that does some processing and
    then sends a request to an ISAPI Ext. (an HTTP Request).
    The code form calling the ISAPI Ext. is as follows :

    HttpWebRequest myHttpWebRequest = null;
    HttpWebResponse myHttpWebResponse = null;
    Stream receiveStream = null;
    StreamReader readStream = null;
    try
    {
    // Creates an HttpWebRequest with the specified URL.
    myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    // Sends the HttpWebRequest and waits for the response.
    myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    // Gets the stream associated with the response.
    receiveStream = myHttpWebResponse.GetResponseStream();
    // Pipes the stream to a higher level stream reader with the required
    encoding format.
    readStream = new StreamReader(receiveStream);
    aResults = readStream.ReadToEnd();
    }
    catch (System.Exception e)
    {
    System.Diagnostics.Trace.WriteLine(e.ToString());
    aResults += "\n" + e.ToString();
    // Releases the resources of the Stream.
    if (readStream != null) readStream.Close();
    // Releases the resources of the response.
    if (myHttpWebResponse != null) myHttpWebResponse.Close();
    return false;
    }
    // Releases the resources of the Stream.
    if (readStream != null) readStream.Close();
    // Releases the resources of the response.
    if (myHttpWebResponse != null) myHttpWebResponse.Close();

    The problem is that I get the following Exception:

    System.Net.WebException: The remote server returned an error: (401)
    Unauthorized.
    at System.Net.HttpWebRequest.CheckFinalStatus()
    at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    at System.Net.HttpWebRequest.GetResponse()
    at ArchiveSearchWebService.ArchiveSearchService.GetSearchResults(String
    aQuery, String& aResults)

    My ASP.NET Web Service allows anonymous access logged in as the ASPNET user,
    and the ISAPI allows anonymous access logged in as the IUSR_<hostname> user.

    Does anyone have an idea as to what my solution might be?

    Thanks,
    Gabby Shainer.
    Gabby Shainer, Nov 4, 2003
    #1
    1. Advertising

  2. I have set the login for the anonymous user on the ISAPI to the ASPNET user
    and set the "allow IIS to control password" checkbox to on.
    The HTTP request seem to work fine now.

    Another problem I'm experiencing now is that when the ISAPI calls a DCOM
    server during its run I get an 80070005 (ACCESS DENIED) error from the DCOM
    server.
    I have given ASPNET both launch and access priveleges on the DCOM server
    (using dcomcnfg).

    Could anyone help me on this one?

    Gabby.

    "Gabby Shainer" <> wrote in message
    news:...
    > Hello,
    >
    > I have an ASP.NET Web Service written in C# that does some processing and
    > then sends a request to an ISAPI Ext. (an HTTP Request).
    > The code form calling the ISAPI Ext. is as follows :
    >
    > HttpWebRequest myHttpWebRequest = null;
    > HttpWebResponse myHttpWebResponse = null;
    > Stream receiveStream = null;
    > StreamReader readStream = null;
    > try
    > {
    > // Creates an HttpWebRequest with the specified URL.
    > myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    > // Sends the HttpWebRequest and waits for the response.
    > myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    > // Gets the stream associated with the response.
    > receiveStream = myHttpWebResponse.GetResponseStream();
    > // Pipes the stream to a higher level stream reader with the required
    > encoding format.
    > readStream = new StreamReader(receiveStream);
    > aResults = readStream.ReadToEnd();
    > }
    > catch (System.Exception e)
    > {
    > System.Diagnostics.Trace.WriteLine(e.ToString());
    > aResults += "\n" + e.ToString();
    > // Releases the resources of the Stream.
    > if (readStream != null) readStream.Close();
    > // Releases the resources of the response.
    > if (myHttpWebResponse != null) myHttpWebResponse.Close();
    > return false;
    > }
    > // Releases the resources of the Stream.
    > if (readStream != null) readStream.Close();
    > // Releases the resources of the response.
    > if (myHttpWebResponse != null) myHttpWebResponse.Close();
    >
    > The problem is that I get the following Exception:
    >
    > System.Net.WebException: The remote server returned an error: (401)
    > Unauthorized.
    > at System.Net.HttpWebRequest.CheckFinalStatus()
    > at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    > at System.Net.HttpWebRequest.GetResponse()
    > at ArchiveSearchWebService.ArchiveSearchService.GetSearchResults(String
    > aQuery, String& aResults)
    >
    > My ASP.NET Web Service allows anonymous access logged in as the ASPNET

    user,
    > and the ISAPI allows anonymous access logged in as the IUSR_<hostname>

    user.
    >
    > Does anyone have an idea as to what my solution might be?
    >
    > Thanks,
    > Gabby Shainer.
    >
    >
    Gabby Shainer, Nov 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Henry
    Replies:
    5
    Views:
    10,017
    Steven Cheng[MSFT]
    Aug 3, 2004
  2. Gerry Hickman
    Replies:
    2
    Views:
    1,489
    Gerry Hickman
    Dec 14, 2005
  3. Jindal, Pankaj

    ['ext.IsDOMString', 'ext.SplitQName']

    Jindal, Pankaj, Dec 22, 2004, in forum: Python
    Replies:
    0
    Views:
    308
    Jindal, Pankaj
    Dec 22, 2004
  4. Replies:
    11
    Views:
    592
  5. Replies:
    0
    Views:
    161
Loading...

Share This Page