Asp.net错误:System.Net.Sockets.SocketException:没有这样的主机是已知的

时间:2017-12-19 16:49:10

标签: c# asp.net signalr

我正在做一些与SignalR一起工作的测试。当我在localhost上进行测试时,结果是成功的,但是当我在生产服务器上发布时,我收到以下错误:

以下错误消息:

No such host is known 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.Sockets.SocketException: No such host is known

enter image description here 我开始的方式如下:

  • 首先我下载了​​signalR数据包
  • 然后我创建了启动文件:

    using System;
    using System.Threading.Tasks;
    using Microsoft.Owin;
    using Owin;
    
    [assembly: OwinStartup(typeof(MvcMasterPrueba.Startup))]
    
    namespace MvcMasterPrueba
    {
       public class Startup
       {
        public void Configuration(IAppBuilder app)
        {
            //ConfigureAuth(app);
            app.MapSignalR();
        }
      }
    }
    

Hub文件:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Microsoft.AspNet.SignalR;

    namespace MvcMasterPrueba
    {
    public class MyHub : Hub
    {
        public void Send(string name, string message)
        {
            Clients.All.broadcastMessage(name, message);
        }

        public void BroadcastMessageToAll(string nombreImpresora, String divHTML)
        {
            //Clients.All.newMessageReceived(message);
            Clients.All.imprimeDiv(nombreImpresora, divHTML);

        }
        public void BroadcastMessageToPrinter(string nombreImpresora, String divHTML)
        {
            Clients.All.imprimeDiv(nombreImpresora, divHTML);
        }

        public void JoinAGroup(string group)
        {
            Groups.Add(Context.ConnectionId, group);
        }

        public void RemoveFromAGroup(string group)
        {
            Groups.Remove(Context.ConnectionId, group);
        }

      }
    }

我在服务器上发布时以及尝试登录时收到错误。也就是说在这一部分:

    public ActionResult Acceder(string User, string Pass)
        {
            string estado = "0";
            string ip = "";
            string db = "";
            string user = "";
            string pass = "";
            string password = "";
            string sql = "SELECT ip,db,user,CONVERT(AES_DECRYPT(`pass`,'1234444444') USING UTF8) AS pass,password " +
                         "FROM usuarios " +
                         "WHERE email='" + User + "' and password='" + Pass + "' limit 1";
            conexion.conectar();
            MySqlDataAdapter datos = new MySqlDataAdapter(sql, conexion.conlogin);
            conexion.cerrar();
            DataTable dt = new DataTable();
            datos.Fill(dt);
            foreach (DataRow row in dt.Rows)
            {
                ip = row[0].ToString();
                db = row[1].ToString();
                user = row[2].ToString();
                pass = row[3].ToString();
                password = row[4].ToString();
            }
            if (Pass == password)
            {
                Session["Session_User"] = User;
                Session["ip"] = ip;
                Session["db"] = db;
                Session["user"] = user;
                Session["pass"] = pass;
                estado = "1";
                Session["ss_nro_caja"] = obtieneNroCaja();
            }
            switch (estado)
            {
                case "0":
                    ViewData["Mensaje"] = "Usuario o Password invalido..!!";
                    return View("Login");
                case "1":
                    FormsAuthentication.SetAuthCookie(User, false);
                    return RedirectToAction("Home", "Acceso");
                default:
                    return View("Login");
            }
        }

所以我得到了这个案子:

    case "1":
                    FormsAuthentication.SetAuthCookie(User, false);
                    return RedirectToAction("Principal", "Acceso");

0 个答案:

没有答案