0

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

4

1 回答 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"));
}
于 2013-05-08T21:41:47.130 回答