Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# visual studio enterprise-负载测试-如何在编码测试中登录到ADFS_C#_Visual Studio_Load Testing_Visual Studio 2015_Adfs - Fatal编程技术网

C# visual studio enterprise-负载测试-如何在编码测试中登录到ADFS

C# visual studio enterprise-负载测试-如何在编码测试中登录到ADFS,c#,visual-studio,load-testing,visual-studio-2015,adfs,C#,Visual Studio,Load Testing,Visual Studio 2015,Adfs,我已根据Microsoft提供的以下说明,在Visual Studio中使用性能/负载测试项目录制了性能测试:。然后我通过点击“生成代码”把它变成了一个编码测试 现在我正在尝试运行测试,但它无法识别它编写的一些代码,比如 request6Body.FormPostParameters.Add("AuthMethod", this.Context["$HIDDEN1.AuthMethod"].ToString()); (在本例中,它表示没有名为“$HIDDEN1.AuthMethod”的上下文参

我已根据Microsoft提供的以下说明,在Visual Studio中使用性能/负载测试项目录制了性能测试:。然后我通过点击“生成代码”把它变成了一个编码测试

现在我正在尝试运行测试,但它无法识别它编写的一些代码,比如

request6Body.FormPostParameters.Add("AuthMethod", this.Context["$HIDDEN1.AuthMethod"].ToString());
(在本例中,它表示没有名为“$HIDDEN1.AuthMethod”的上下文参数)

我知道这可能是因为ADFS屏幕每次都不会返回相同的标题等,但是有人编写了代码来解决这个问题,如果有,是怎么做的


谢谢

在我们的测试中,我开发了一种允许使用模拟/假登录的方法,允许您在没有ADF和重定向的情况下使用应用程序。当然,这应该在生产中禁用。下一次记录测试时,您可以直接从假登录开始

我们使用ASP.NETMVC,所以我只能向您展示如何在ASP.NETMVC中工作

控制器动作 (因此您可以执行:/Home/模拟/demouser@example.com

Impersonalisator.ImpersonateByMail
您可以开始登录而不必检查ADF,您也不希望在测试中使用ADF或其他身份验证服务,例如,在负载测试中,您可能会“攻击”这些服务会导致失败等。

这通常意味着测试早期的某些内容失败,因此发送了不同的响应;可能是错误页面。此不同页面不包含所需的隐藏参数。
    [AllowAnonymous]
    public ActionResult Impersonate([Bind(Prefix = "id")]string email)
    {
        Impersonalisator.ImpersonateByEMail(email, Request);
        return RedirectToRoute("Default", new { action = string.Empty, controller = string.Empty });
    }
    public static void ImpersonateByEMail(string email, HttpRequestBase request)
    {
        // you don't need this if clause, or you introduce this appsetting in your web.config
        if ("true" == ConfigurationManager.AppSettings["EnableImpersonate"])
        {
            var impersonatedIdentity = new ClaimsIdentity("ApplicationCookie");

            impersonatedIdentity.AddClaim(new Claim(ClaimTypes.Email, email));

            // Add other claims you might need

            var owinContext = request.GetOwinContext();
            owinContext.Authentication.SignOut("ApplicationCookie");
            owinContext.Authentication.SignIn(impersonatedIdentity);
        }
    }