mardi 5 mai 2015

how to set the user agent property for HttpRequest?

I am trying to create a fake HttpContext for my unit test and also wanted to set the user agent property.

I tried the below code , but it failed saying platform not supported.

            var httpRequest = new HttpRequest(null, "http:xyz.com", null);
            httpRequest.Headers["UserAgent"] = "unitTest";

            var stringWriter = new StringWriter();
            var httpResponce = new HttpResponse(stringWriter);
            HttpContext context = new HttpContext(httpRequest, httpResponce);

any help ?

Aucun commentaire:

Enregistrer un commentaire