How to set ScriptingContext Response cookie after upgrade to .Net

限于喜欢 提交于 2019-12-04 18:24:05

Need to convert cookie item to IWriteCookie interface. Then it will be writable.

Imports ASPTypeLibrary
Public Class Test
    Private oContext As ASPTypeLibrary.ScriptingContext
    Private oResponse As ASPTypeLibrary.Response
    Public Sub OnStartPage(e As ScriptingContext)
        oContext = e
        oResponse = oContext.Response
        With CType(oResponse.Cookies("fromdotnet"), IWriteCookie)
            .Item = String.Format("hello from .Net : {0}", Date.UtcNow())
            '.Domain = ""
            '.Path = "/"
            '.Secure = False
        End With
    End Sub
End Class

You may want to check out other interfaces such as IReadCookie, IStringList, IRequestDictionary etc.

With note that:

Full trust for the immediate caller. This member cannot be used by partially trusted code.

there is another option : ContextUtil.GetNamedProperty Method

System.EnterpriseServices.ContextUtil.GetNamedProperty("Response").Cookies("fromdotnet") = "hello"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!