Vmware + CentOS 7 + Jexus 5.8.3 独立版部署 + .Net Core

2019-01-02 20:33发布

问题:

Controller代码:

public SiteConfig config;
public static IDbConnection conn;
public HomeController(IOptionsSnapshot<SiteConfig> option)
{
config = option.Value;
conn = new SqlConnection(config.value);
}

    public IActionResult Index()
    {
        using (conn)
        {
            ContentModel m = new ContentModel
            {
                title = "这里是标题1",
                content = "这里是内容2",
                adddate = DateTime.Now
            };
            string sql = "insert into content(title,content,adddate) values(@title,@content,@adddate)";
            int i = conn.Execute(sql.ToString(), new { title = m.title, content = m.content, adddate = m.adddate });
            ViewBag.a = i.ToString();
            return View();
        }
    
    }

appsettings.json 代码:

{
"SiteConfig": {
"name": "test",
"value": "Data Source=192.168.11.209; Initial Catalog=MyBlog;User ID=sa;Password=sa"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}

在vs中都正常,但是部署到jexus中时,数据库老是超时。没有数据库操作的页面,都正常。

回答1:

你虚拟机里面,网络通畅吗,或者说,能访问到数据库服务器的ip吗



标签: