Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9035261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:42:48+00:00 2026-06-16T08:42:48+00:00

I have two websites set up on my local system running IIS 5.1 (on

  • 0

I have two websites set up on my local system running IIS 5.1 (on localhost). I am calling one website from another. I am working with ASP.NET, C# 2.0.

public static String executeWebRequest(string url, Boolean esmRequest)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        UTF8Encoding encoding = new UTF8Encoding();
        Stream requestStream = null;
        HttpWebResponse response = null;
        StreamReader responseStream = null;
        string responseString;

        try
        {
            //post request
            request.Method = "POST";

            if (esmRequest)
            {
                //request.UseDefaultCredentials = true;
                request.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ESMServerUserName"], ConfigurationManager.AppSettings["ESMServerPassword"]);
            }
            else
            {
                //request.UseDefaultCredentials = true;
                request.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ESMServerUserName"], ConfigurationManager.AppSettings["ESMServerPassword"]);
            }

            requestStream = request.GetRequestStream();
            requestStream.Write(new byte[0], 0, 0);
            requestStream.Close();

            //get response
            response = (HttpWebResponse)request.GetResponse();
            responseStream = new StreamReader(response.GetResponseStream(), encoding);
            responseString = responseStream.ReadToEnd();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (requestStream != null)
            {
                requestStream.Close();
            }

            if (response != null)
            {
                response.Close();
            }

            if (responseStream != null)
            {
                responseStream.Close();
            }
        }

        return responseString;
    }
}

I run this code and get a 401 HTTP status code. 1 errorm whereas when I paste the same URL in the browser it executes perfectly.

I already have DisableLoopbackCheck enabled using http://support.microsoft.com/kb/89686/en-us

How can I resolve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:42:49+00:00Added an answer on June 16, 2026 at 8:42 am

    I was able to fix it with this change

    var cache = new CredentialCache();
    
    NetworkCredential credential = new NetworkCredential(ConfigurationManager.AppSettings["ESMServerUserName"], ConfigurationManager.AppSettings["ESMServerPassword"]);
    
    cache.Add(new Uri(url), "Basic", credential);
    request.Credentials = cache;       
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two websites running on one server in IIS7.5 and would like to
I have two websites, both using .Net framework 3.5. One website is hosting a
I have two websites running on the same Windows 2008r2 64bit server, SQL Server
I have two websites running on my own root server (ubuntu/nginx/php-fpm). Now I want
What's the best way to have two websites (asp.net based) running on different domains
I have a very strange issue on my hands. I have two IIS websites
I have two websites on IIS 6 that throw server errors when they are
I have two IIS websites, namely accounts.example.com that was created in Visual Studio 2010
We have a Windows Server 2003 machine running IIS6.0 that hosts two different websites.
I forgot how I set it. I have two websites and I send the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.