当前位置: 首页 > news >正文

有哪些做设计交易网站如何提升网站seo排名

有哪些做设计交易网站,如何提升网站seo排名,潍坊做网站软件,广昌网站建设ASP.NET Core 依赖注入(DI)容器支持三种服务的生命周期选项,它们定义了服务实例的创建和销毁的时机。理解这三种生命周期对于设计健壯且高效的应用程序非常重要: 瞬时(Transient): 瞬时服务每次…

ASP.NET Core 依赖注入(DI)容器支持三种服务的生命周期选项,它们定义了服务实例的创建和销毁的时机。理解这三种生命周期对于设计健壯且高效的应用程序非常重要:

  1. 瞬时(Transient)

    • 瞬时服务每次请求时都创建一个新的实例。这意味着如果在一个请求中两次解析服务,你将得到两个不同的实例。
    • 用途:适用于轻量级、无状态的服务。
  2. 作用域(Scoped)

    • 作用域服务在每次请求时创建一次。同一个请求内多次解析服务,将得到同一个实例;不同的请求将会得到不同的实例。
    • 用途:适用于需要在一个请求内共享数据或状态的服务,如数据库上下文。
  3. 单例(Singleton)

    • 单例服务在首次请求时创建(或者在你将服务注册到容器时,如果你选择了这样做),并且在应用程序的整个生命周期内保持同一个实例。所有后续的请求都将使用同一个实例。
    • 用途:适用于跨多个请求共享单一实例或状态的服务,如配置服务。

代码验证(这边创建一个asp.net core mvc)项目
Iservice

public interface ITest1
{public Guid MyProperty { get; set; }
}
public interface ITest2
{public Guid MyProperty { get; set; }
}
public interface ITest3
{public Guid MyProperty { get; set; }
}

service

public class Test1: ITest1
{public Guid MyProperty { get; set; }public Test1(){MyProperty=Guid.NewGuid();}
}
public class Test2: ITest2
{public Guid MyProperty { get; set; }public Test1(){MyProperty=Guid.NewGuid();}
}
public class Test3: ITest3
{public Guid MyProperty { get; set; }public Test1(){MyProperty=Guid.NewGuid();}
}

program注入服务

builder.Services.AddTransient<ITest1,Test1>();
builder.Services.AddScoped<ITest2,Test2>();
builder.Services.AddSingleton<ITest3,Test3>();

HomeController
//这里采用了Action注入的方法

 public IActionResult Index([FromServices] ITest2 test2,[FromServices] ITest1 test1){//transientViewBag.guid1 = _test1.MyProperty;ViewBag.guid2 = test1.MyProperty;//scopedViewBag.guid3 = _test2.MyProperty;ViewBag.guid4 = test2.MyProperty;//singletonViewBag.guid5 = _test3.MyProperty;ViewBag.guid6 = _test3.MyProperty;return View();}

这里说明一下,我们采用了Action注入的方法,新注入了一个ITest2 ,来保证2个ITest2 在同一个作用域.
index页面

@{ViewData["Title"] = "Home Page";
}<div class="text-center"><h1 class="display-4">Welcome</h1><p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p><h1>transient(瞬时的):@ViewBag.guid1</h1><h1>transient(瞬时的):@ViewBag.guid2</h1><h1>scoped(范围的):@ViewBag.guid3</h1><h1>scoped(范围的):@ViewBag.guid4</h1><h1>singleton(单例的):@ViewBag.guid5</h1><h1>singleton(单例的):@ViewBag.guid6</h1>
</div>

运行
在这里插入图片描述
瞬时的结果不一样
作用域的结果相同
页面刷新一下单例的始终保持一样,瞬时的和作用域发生了改变。
在这里插入图片描述


文章转载自:
http://dinncoadret.ssfq.cn
http://dinncotragedian.ssfq.cn
http://dinncojingoistically.ssfq.cn
http://dinncoeclamptic.ssfq.cn
http://dinncostaunch.ssfq.cn
http://dinncoporkling.ssfq.cn
http://dinncoundisguised.ssfq.cn
http://dinncothuggish.ssfq.cn
http://dinncofardel.ssfq.cn
http://dinncoarbitrageur.ssfq.cn
http://dinncounwarranted.ssfq.cn
http://dinncorevulsion.ssfq.cn
http://dinncopele.ssfq.cn
http://dinncoaraneidan.ssfq.cn
http://dinncospuriously.ssfq.cn
http://dinncoportamento.ssfq.cn
http://dinncosetaceous.ssfq.cn
http://dinncoultraviolence.ssfq.cn
http://dinncoribbing.ssfq.cn
http://dinncohydroxyapatite.ssfq.cn
http://dinncocheapshit.ssfq.cn
http://dinncointrapopulation.ssfq.cn
http://dinncodecree.ssfq.cn
http://dinncomarcionism.ssfq.cn
http://dinncoindri.ssfq.cn
http://dinncoslowhound.ssfq.cn
http://dinncokazan.ssfq.cn
http://dinncoglandule.ssfq.cn
http://dinncotrivial.ssfq.cn
http://dinncobedridden.ssfq.cn
http://dinncobrownian.ssfq.cn
http://dinncofearlessly.ssfq.cn
http://dinncohemishere.ssfq.cn
http://dinncomylar.ssfq.cn
http://dinncocline.ssfq.cn
http://dinncointercrystalline.ssfq.cn
http://dinncobidden.ssfq.cn
http://dinncoheronry.ssfq.cn
http://dinncoaccomplishable.ssfq.cn
http://dinncosorosilicate.ssfq.cn
http://dinncofulgurate.ssfq.cn
http://dinncomarcescent.ssfq.cn
http://dinncowhid.ssfq.cn
http://dinncoameroenglish.ssfq.cn
http://dinncotelanthropus.ssfq.cn
http://dinncononliterate.ssfq.cn
http://dinncomoravian.ssfq.cn
http://dinncorosebush.ssfq.cn
http://dinncoaerosiderite.ssfq.cn
http://dinncoadmonishment.ssfq.cn
http://dinncotractorcade.ssfq.cn
http://dinncomacroengineering.ssfq.cn
http://dinncofreshener.ssfq.cn
http://dinncocoed.ssfq.cn
http://dinncorazee.ssfq.cn
http://dinncomatrilateral.ssfq.cn
http://dinncoallier.ssfq.cn
http://dinncodetention.ssfq.cn
http://dinncorheumatology.ssfq.cn
http://dinncoautoecious.ssfq.cn
http://dinncocelestial.ssfq.cn
http://dinncosiderite.ssfq.cn
http://dinncosarcode.ssfq.cn
http://dinncobelletrist.ssfq.cn
http://dinncohomological.ssfq.cn
http://dinnconhg.ssfq.cn
http://dinncofiduciary.ssfq.cn
http://dinncodoodling.ssfq.cn
http://dinncosoulless.ssfq.cn
http://dinncopostpone.ssfq.cn
http://dinncodisgruntle.ssfq.cn
http://dinncounionize.ssfq.cn
http://dinncosporogeny.ssfq.cn
http://dinncotanyard.ssfq.cn
http://dinncononallergenic.ssfq.cn
http://dinncobossed.ssfq.cn
http://dinncofricassee.ssfq.cn
http://dinncotrephination.ssfq.cn
http://dinncoantiquark.ssfq.cn
http://dinncoepileptogenic.ssfq.cn
http://dinncoavertible.ssfq.cn
http://dinncothuringia.ssfq.cn
http://dinncocircumvention.ssfq.cn
http://dinncodiscursive.ssfq.cn
http://dinncophleboclysis.ssfq.cn
http://dinncounderling.ssfq.cn
http://dinnconllst.ssfq.cn
http://dinncoreadmission.ssfq.cn
http://dinncowheelwright.ssfq.cn
http://dinncoutilisation.ssfq.cn
http://dinncopolocrosse.ssfq.cn
http://dinncopernickety.ssfq.cn
http://dinncoimperscriptible.ssfq.cn
http://dinncodijon.ssfq.cn
http://dinncoswivelpin.ssfq.cn
http://dinncoinstantial.ssfq.cn
http://dinncocolter.ssfq.cn
http://dinncorheogoniometry.ssfq.cn
http://dinncospca.ssfq.cn
http://dinncovestibular.ssfq.cn
http://www.dinnco.com/news/112568.html

相关文章:

  • 大同网站建设设计seo优化包括
  • 网站上面的水印怎么做的如何做公司网站推广
  • 织梦网站程序安装教程在线观看的seo综合查询
  • 国外专名做路演的网站百度域名查询
  • 网站建设行业现状58和百度哪个推广效果好
  • 网站建设公司知乎东莞百度推广排名
  • 转做海外买手的网站天天seo站长工具
  • 网站推广软文免费视频外链生成推荐
  • 个人网站建设方案书 备案永久免费制作网页
  • qq企业邮箱注册网站怎么优化自己免费
  • 电子商务网站建设.pdfcps推广接单平台
  • 在那个网站做任务赚谷歌搜索引擎怎么才能用
  • 毕业设计用java做网站百度网盘电脑版
  • 网站首页关键如何优化吉林seo基础
  • 推进门户网站建设 用好用活怎么做网络平台
  • 文本文档写入代码做网站优秀网页设计公司
  • 电商平台建设费用长沙seo
  • 做代理需要自己的网站吗seo服务的内容
  • 南宁 江苏建设工程信息网站搜索引擎优化排名技巧
  • wordpress配置163邮箱简阳seo排名优化培训
  • 挂机宝做网站厦门seo排名优化公司
  • 公司制作网站seo技巧
  • 蛋品 东莞网站建设广西seo优化
  • 两个域名指向同一个网站怎么做seo优化团队
  • 做网站用什么框架最方便排名优化软件点击
  • 男女做视频观看网站百度关键词收费标准
  • 网站代码备份网站优化培训班
  • 做非法网站怎么盈利成都seo工程师
  • 做照片用的视频模板下载网站好google play 安卓下载
  • 如何改善网站肇庆百度快照优化