English 中文(简体)
这部网络的代码是,NOT实际上会形成一种 co,正确吗?
原标题:This .NET code snippet will NOT actually create a cookie, right?

我刚刚认识到,这座厨师并没有像现在这样表现出来,我检查了我没有写成的法典,但我很相信,这足以制造一种 co子吗?

public static void CreateSSOCookies(string tokenID)
            {
                System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
                System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Value = tokenID.ToString();
                System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Path = "~/";
                System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(7);
            }

如果是工作,那是哪里? co子名称是否 s?

最佳回答
问题回答

我认为,戴维在评论这个问题时是正确的,但是为了扩大他的意见:

“~/”轨道是特别针对伙伴关系的。 NET,并赢得你所期望的道路。 因此,厨师实际上正在创建,但既然你重新树立了一条无效的道路,那就没有回到你。

例如,如果你走到“foo”的道路,那么,只有在你提出申请时,才能将 co子送回到<代码>/foo。

由于你的申请中没有任何一条与字面<代码>~/等同的绝对道路,因此, co子胜出。

它确实创造了一种 co。 综观一下,你前面的法典就是这样说:

public HttpCookie this[string name]
{
    get
    {
            return this.Get(name);
    }
}

这反过来又要求:

public HttpCookie Get(string name)
{
    HttpCookie cookie = (HttpCookie) base.BaseGet(name);
    if ((cookie == null) && (this._response != null))
    {
        cookie = new HttpCookie(name);
        this.AddCookie(cookie, true);
        this._response.OnCookieAdd(cookie);
    }
    return cookie;
}

你们可以看到,这实际上造成了一种 co。 如果你看不到这一请求,我认为它必须走你的道路。 我并不肯定“~/”是有效的。

HttpCookie myCookie = new HttpCookie("UserSettings");
myCookie["Font"] = "Arial";
myCookie["Color"] = "Blue";
myCookie.Expires = DateTime.Now.AddDays(1d);
Response.Cookies.Add(myCookie); //<<<<<<<<<-------------------

80)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签