2021-10-07 13:41:08 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,csharp]
|
2021-10-07 13:41:08 +02:00
|
|
|
----
|
|
|
|
using System.Web;
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
|
|
[HttpGet]
|
2021-10-12 14:53:05 +02:00
|
|
|
public ActionResult index(string val)
|
2021-10-07 13:41:08 +02:00
|
|
|
{
|
2021-10-12 14:53:05 +02:00
|
|
|
Response.AddHeader("Set-Cookie", val); // Noncompliant
|
|
|
|
HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", val); // Noncompliant
|
2021-10-07 13:41:08 +02:00
|
|
|
Response.AppendCookie(cookie);
|
|
|
|
return View("");
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,csharp]
|
2021-10-07 13:41:08 +02:00
|
|
|
----
|
|
|
|
using System.Web;
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
public ActionResult index(string val)
|
|
|
|
{
|
|
|
|
Response.AddHeader("X-Data", val);
|
|
|
|
HttpCookie cookie = new HttpCookie("data", val);
|
|
|
|
Response.AppendCookie(cookie);
|
|
|
|
return View("");
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
|
|
|
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
|
2021-10-12 14:53:05 +02:00
|
|
|
endif::env-github,rspecator-view[]
|