首页 文章

POST asp.net表单用户名和密码到外部HTTPS登录

提问于
浏览
0

我是asp.net c#的新手 . 我创建了一个登录表单,当用户提交时,会将他们的用户名和密码POST到我的应用程序之外的安全外部登录表单 . 我尝试通过设置httprequest来做到这一点,但它没有用 . 在asp.net中使用c#执行此操作的最佳方法是什么?

1 回答

  • 1

    这是一个非常简单的例子 . 我希望这是你需要的:

    using (var webClient = new WebClient())
    {
        webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        var result = webClient.UploadString("https://your-url.com", string.Format("username={0}password={1}", "usernamegoeshere", "paswordgoeshere"));
    }
    

相关问题