rspec/rules/S6287/csharp/rule.adoc

48 lines
848 B
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
----
using System.Web;
using System.Web.Mvc;
[HttpGet]
public ActionResult index(string key, string val)
{
Response.AddHeader(key, val); // Noncompliant
HttpCookie cookie = new HttpCookie(key, val); // Noncompliant
Response.AppendCookie(cookie);
return View("");
}
----
== Compliant Solution
----
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[]
endif::env-github,rspecator-view[]