Files
COMCMS/COMCMS.Web/Controllers/HomeController.cs
T
2018-04-22 00:25:55 +08:00

65 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using COMCMS.Web.Models;
using COMCMS.Common;
using COMCMS.Core;
using XCode;
using System.Text;
using System.IO;
namespace COMCMS.Web.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
CookiesHelper.WriteCookie("abc", Utils.GetRandomChar(20), 10);
//sessiong
SessionHelper.WriteSession("bcd", Utils.GetRandomChar(20));
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
Config cfg = Config.FindById(1);
ViewBag.siteName = cfg.SiteName;
ViewBag.c = CookiesHelper.GetCookie("abc");
ViewBag.d = Utils.GetServerUrl();
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
#region 测试
public IActionResult Test()
{
JsonTip json = new JsonTip();
string strJson = JsonTip.GetJsonString(json);
//Byte[] bytes = Encoding.UTF8.GetBytes(strJson);
//Stream stream = new MemoryStream(bytes);
//MyHttpContext.Current.Response.ContentType = "text/plain";
//MyHttpContext.Current.Response.Body = stream;
return Content("ok");
}
#endregion
}
}