初步增加首页
This commit is contained in:
@@ -15,54 +15,29 @@ using Microsoft.Extensions.Configuration.Json;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Concurrent;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
|
||||
namespace COMCMS.Web.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
public class HomeController : HomeBaseController
|
||||
{
|
||||
public static IConfiguration Configuration { get; set; }
|
||||
public ConcurrentDictionary<string, string> AllSession = new ConcurrentDictionary<string, string>();
|
||||
|
||||
public HomeController(IConfiguration configuration)
|
||||
{
|
||||
//Configuration = new ConfigurationBuilder()
|
||||
// .SetBasePath(Directory.GetCurrentDirectory())
|
||||
// .AddJsonFile("appsettings.json", optional: true, reloadOnChange : true)
|
||||
// .Build();
|
||||
Configuration = configuration;
|
||||
}
|
||||
#region 首页
|
||||
public IActionResult Index()
|
||||
{
|
||||
CookieOptions op = new CookieOptions
|
||||
{
|
||||
Expires = DateTime.Now.AddMinutes(10),
|
||||
Path = "/",
|
||||
HttpOnly = true
|
||||
};
|
||||
Response.Cookies.Append("abc", "123456", op);//用户名
|
||||
|
||||
|
||||
|
||||
ViewBag.cfg = cfg;
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public IActionResult About()
|
||||
{
|
||||
ViewData["Message"] = "Your application description page.";
|
||||
CookiesHelper.WriteCookie("abc", Utils.GetRandomChar(20), 10);
|
||||
//sessiong
|
||||
SessionHelper.WriteSession("bcd", Utils.GetRandomChar(20));
|
||||
HttpContext.Session.SetString("abc", "123456");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Contact()
|
||||
{
|
||||
Link l = Link.Find(Link._.Id == 1);
|
||||
l.Title = "😂😂😂😂";
|
||||
l.Save();
|
||||
return View(l);
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
@@ -70,84 +45,5 @@ namespace COMCMS.Web.Controllers
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
#region 测试
|
||||
public IActionResult Test()
|
||||
{
|
||||
var css = Configuration.GetSection("connectionStrings");
|
||||
var list = css.GetChildren();
|
||||
if(list !=null && list.Count() > 0)
|
||||
{
|
||||
|
||||
}
|
||||
string s = "";
|
||||
foreach (var item in list)
|
||||
{
|
||||
string connName = item.Path.Substring(item.Path.IndexOf(":") + 1);
|
||||
string connectionString = css.GetSection(connName).GetSection("connectionString").Value;
|
||||
string providerName = css.GetSection(connName).GetSection("providerName").Value;
|
||||
s += item.Path.Substring(item.Path.IndexOf(":")+1)+ "|"+ Configuration.GetSection(item.Path+ ":connectionString").Value+"|" + Configuration.GetSection(item.Path + ":providerName").Value +"|"+connectionString+"|"+ providerName +"|||" + list.Count();
|
||||
}
|
||||
|
||||
return Content(s);
|
||||
}
|
||||
|
||||
public IActionResult Test2()
|
||||
{
|
||||
var settings = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");
|
||||
var css2 = new ConfigurationBuilder().AddJsonFile(settings).Build().GetSection("connectionStrings");
|
||||
|
||||
string s = "";
|
||||
if (css2 != null)
|
||||
{
|
||||
foreach (var item in css2.GetChildren())
|
||||
{
|
||||
var name = item.Path.Substring(item.Path.IndexOf(":") + 1);// item["name"];
|
||||
var constr = item["connectionString"];
|
||||
var provider = item["providerName"];
|
||||
s += $"{name}|{constr}|{provider}|||";
|
||||
//var type = DbFactory.GetProviderType(constr, provider);
|
||||
//if (type == null) XTrace.WriteLine("无法识别{0}的提供者{1}!", name, provider);
|
||||
|
||||
//cs.Add(name, constr);
|
||||
//_connTypes.Add(name, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Content(s);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MyRegion
|
||||
public IActionResult Test3()
|
||||
{
|
||||
bool isok = false;
|
||||
if(AllSession.TryAdd(HttpContext.Session.Id, HttpContext.Session.Id))
|
||||
{
|
||||
isok = true;
|
||||
}
|
||||
|
||||
return Content(isok.ToString() + ":" + JsonConvert.SerializeObject(AllSession));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 测试
|
||||
[HttpGet]
|
||||
public IActionResult Article(string title)
|
||||
{
|
||||
return Content(title);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public IActionResult Uploader()
|
||||
{
|
||||
return View("~/Areas/AdminCP/Views/WebUploader/Uploader.cshtml");
|
||||
}
|
||||
|
||||
public IActionResult FileTest()
|
||||
{
|
||||
return View();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,5 @@ namespace COMCMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
public wxpaymentController(IConfiguration configuration) : base(configuration){}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user