简体   繁体   English

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

[英]POST asp.net form username and password to an external HTTPS login

I am new to asp.net c#. 我是asp.net C#的新手。 I have created a login form that when the user submits will POST their username and password to a secure external login form outside of my application. 我创建了一个登录表单,当用户提交该表单时,会将其用户名和密码发布到应用程序外部的安全外部登录表单中。 I tried doing this by setting up a httprequest but it did not work. 我尝试通过设置httprequest来做到这一点,但是它没有用。 What is the best way of doing this with c# in asp.net. 在asp.net中使用c#做到这一点的最佳方法是什么。

Here's a very simple example. 这是一个非常简单的示例。 I hope this is what you need: 我希望这是您需要的:

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"));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM