如何在html中使用会话的值?

时间:2018-07-07 05:40:28

标签: html asp.net asp.net-mvc razor

假设我有Jul 7 05:08:41 localhost journal: E0707 05:08:41.853267 1 datacenter.go:78] Unable to find VM by UUID. VM UUID: Jul 7 05:08:41 localhost journal: E0707 05:08:41.853374 1 nodemanager.go:414] Error "No VM found" node info for node "engine01" not found Jul 7 05:08:41 localhost journal: E0707 05:08:41.853416 1 vsphere_util.go:134] Error while obtaining Kubernetes node nodeVmDetail details. error : No VM found Jul 7 05:08:41 localhost journal: E0707 05:08:41.853444 1 vsphere.go:1160] Failed to get shared datastore: No VM found Jul 7 05:08:41 localhost journal: I0707 05:08:41.854301 1 event.go:221] Event(v1.ObjectReference{Kind:"PersistentVolumeClaim", Namespace:"default", Name:"test-disk", UID:"a7c88c13-813d-11e8-aa8c-0050568166d0", APIVersion:"v1", ResourceVersion:"31538424", FieldPath:""}): type: 'Warning' reason: 'ProvisioningFailed' Failed to provision volume with StorageClass "thin-disk": No VM found Jul 7 05:08:43 localhost journal: I0707 05:08:43.768259 1 reconciler.go:291] attacherDetacher.AttachVolume started for volume "pvc-a3091746-6a16-11e8-87de-0050568166d0" (UniqueName: "kubernetes.io/vsphere-volume/[3PAR_Datastore06] kubevols/kubernetes-dynamic-pvc-a3091746-6a16-11e8-87de-0050568166d0.vmdk") from node "engine02" Jul 7 05:08:43 localhost journal: E0707 05:08:43.785846 1 datacenter.go:78] Unable to find VM by UUID. VM UUID: Jul 7 05:08:43 localhost journal: E0707 05:08:43.785913 1 nodemanager.go:282] Error "No VM found" node info for node "engine02" not found Jul 7 05:08:43 localhost journal: E0707 05:08:43.785938 1 vsphere.go:550] Cannot find node "engine02" in cache. Node not found!!! Jul 7 05:08:43 localhost journal: E0707 05:08:43.786012 1 attacher.go:80] Error attaching volume "[3PAR_Datastore06] kubevols/kubernetes-dynamic-pvc-a3091746-6a16-11e8-87de-0050568166d0.vmdk" to node "engine02": No VM found ,它是整数。 此外-我想在我的HTML代码中使用此值(我想在视图中显示此值)。

有什么办法吗?

4 个答案:

答案 0 :(得分:0)

要在View中访问会话,您可以执行以下操作。

HttpContext.Current.Session["myvalue"].ToString()

如果是物体或其他东西,则必须装箱。

   <<your type>> nameofVariable = (<<your type>>)HttpContext.Current.Session["myvalue"]

除此之外,您还必须检查null和所有内容。

答案 1 :(得分:0)

这是方法

<%:Session["myvalue"]%>

如果遇到错误,请使用

<%:Session["myvalue"].ToString()%>

答案 2 :(得分:0)

  • 如果您使用的是MVC,则可以使用@Session["myvalue"]

  • 如果您使用的是Asp.net,则可以使用<%:Session["myvalue"].ToString()%>

答案 3 :(得分:0)

只需在会话变量前面使用@符号,就需要将会话作为一个整数

  

@(int)Session [“ myvalue”]