rspec/rules/S6287/csharp/rule.adoc

51 lines
894 B
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,csharp]
----
using System.Web;
using System.Web.Mvc;
[HttpGet]
2021-10-12 14:53:05 +02:00
public ActionResult index(string val)
{
2021-10-12 14:53:05 +02:00
Response.AddHeader("Set-Cookie", val); // Noncompliant
HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", val); // Noncompliant
Response.AppendCookie(cookie);
return View("");
}
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,csharp]
----
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[]
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[]