Google Chrome与localhost的连接尝试遭到拒绝。网站可能已关闭,或者您的网络可能未正确配置。 [英] Google Chrome's connection attempt to localhost was rejected. The website may be down, or your network may not be properly configured.

查看:1231
本文介绍了Google Chrome与localhost的连接尝试遭到拒绝。网站可能已关闭,或者您的网络可能未正确配置。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我创建一个Hello wcf服务,它返回一个字符串,代码如下:




app.config中的代码文件



Here i'am creating a Hello wcf service which returns a string and the code is following


code in app.config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="WcfDemo.HelloService" behaviorConfiguration="mexBehaviour">
        <endpoint address="HelloService" binding="basicHttpBinding" contract="WcfDemo.IHelloService"></endpoint>
        <endpoint address="HelloService" binding="netTcpBinding" contract="WcfDemo.IHelloService"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8010/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>







和wcf服务中的代码是






and code in wcf service is

namespace WcfDemo
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "HelloService" in code, svc and config file together.
    public class HelloService : IHelloService
    {

        public string Hello(string Name)
        {
           return "Hello " + Name;
        }
    }
}







代码自动生成classfile是








Code in automatically generated classfile is


namespace WcfDemo
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IHelloService" in both code and config file together.
    [ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        string Hello(string Name);
    }
}







i已在控制台应用程序中托管此wcf服务代码是






i have hosted this wcf service in console application and the code is

namespace HelloServicehost
{
    class Program
    {
        static void Main()
        {
            using (ServiceHost host = new ServiceHost(typeof(WcfDemo.HelloService)))
            {
                host.Open();
                Console.WriteLine("Service Started at @ " + DateTime.Now.ToString());
                Console.ReadLine();
            }
        }
    }
}







这里控制台应用程序成功托管在consoleapplication中但当我试图打开http:// localhost:8080 / iam时没有获取wsdl文件。



错误IAM获取

(Google Chrome与localhost的连接尝试被拒绝。网站可能已关闭,或者您的网络可能没有正确配置)。如何解决它?

实际上我学习了wcf服务,所以我找不到错误是从浏览器还是从应用程序抛出。有人帮我提前谢谢。




Here console application is hosted in consoleapplication successfully but when i trying to open http://localhost:8080/ iam not getting the wsdl document.

THE ERROR IAM GETTING IS
(Google Chrome's connection attempt to localhost was rejected. The website may be down, or your network may not be properly configured). HOW TO SOLVE IT?
actually iam learner of wcf services so i could not find the whether the error is thrown from the browser or from the application. some one help me thanks in advance.

推荐答案

我可能会迟到回答,但'使用'的事情就是它尽快关闭连接打开

您可以使用类似



ServiceHost host = new ServiceHost(typeof(CalcService.CalcService));



host.Open();
I might be late in answering,but the thing with 'using' is that its closing the connection just as soon as it opens
You can use something like

ServiceHost host = new ServiceHost(typeof(CalcService.CalcService));

host.Open();


这篇关于Google Chrome与localhost的连接尝试遭到拒绝。网站可能已关闭,或者您的网络可能未正确配置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆