HttpWebResponse displays siteminder login even though URLs are configured to be by passed in Siteminder

677 Views Asked by At

I am stumped on this problem and have come humbled to the experts on advice for my problem.

I have an ASP.NET MVC app that is Siteminder enabled. In addition, this app has a section of URLS that are web services which provide data to another application. Those URLS have been configured for "bypass" Siteminder authentication in the Siteminder setup. I've double checked the bypass to make sure the Siteminder configuration is correct. I can enter those URLs in a browser and the JSON data is displayed "without" Siteminder authentication. However....

The problem is when I use HttpWebResponse, Stream and StreamReader to retrieve the JSON data when siteminder is enabled, I get the Siteminder "login page HTML" as the string when StreamReader.ReadToEnd() is evoked instead of the JSON formatted data???

This is baffling because I another developer here can access the same web service and get the "correct" JSON formatted data in a PYTHON app. Also, I put it in a regular ASP.NET app so it's not an MVC issue. I get the same result.

Is there another class or library I should use? Is there a configuration setting I need to pass to the web service call? Any help would be greatly appreciated.

Here is the code of one of the web service calls.

        public static string GetData()
    {
        string host = (string)System.Configuration.ConfigurationManager.AppSettings["WEBSERVICE_GET"];
        string URL = host + "Api/GetData";
        var end = string.Empty;

        try
        {
            HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest;

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            using (Stream responseStream = response.GetResponseStream())
            {
                if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created)
                {
                    throw new HttpException((int)response.StatusCode, response.StatusDescription);
                }


                using (StreamReader reader = new StreamReader(responseStream))
                {
                    end = reader.ReadToEnd();
                    reader.Close();
                }

                responseStream.Close();
                response.Close();


            }

        }
        catch (Exception ex)
        {
            EmailNotification.SendErrorEmail("Could not get Data from WEBSERVICE + ex);
        }

        return end;

    }
0

There are 0 best solutions below