更新时间:2022-01-17 22:27:46
如果你是虚拟主机,为什么不呢?
If you are web hosting, why not?
var context = HttpContext.Current;
if (context != null)
{
if (context.Cache["g"] == null)
{
context.Cache["g"] = 9.81;
}
}
但是,你正在对ASP.NET依赖这样做。正如你可能知道,的ASP.NET Web API虽然已经ASP.NET中的名称是主机无关,ASP.NET/IIS不是唯一的宿主选项。它可以是自托管为好。东西给你才走这路线来考虑。
But you are taking a dependency on ASP.NET by doing so. As you might know, ASP.NET Web API though has ASP.NET in the name is host-agnostic and ASP.NET/IIS is not the only hosting option. It can be self-hosted as well. Something for you to consider before going down that route.