[英]Can i post data(username and password) to another website from my .NET web application to get login?
I am working in .NET web based application, what i wanted to do is that i want to pass a username and password from my .NET web app to another python based web application ( http://172.20.47.21:8069/web/login ) and post the data to that server to get login into that account. 我正在基于.NET Web的应用程序中工作,我想做的是将用户名和密码从.NET Web应用程序传递给另一个基于python的Web应用程序( http://172.20.47.21:8069/web/ login )并将数据发布到该服务器以登录该帐户。 Is is possible with some .NET code or Javascript code ?
某些.NET代码或Javascript代码可能吗? If it is then how ?
如果是这样怎么办? I don't want to open a login page of that python web app.
我不想打开该python Web应用程序的登录页面。 I want to post that form from my .NET app and after successful authentication i should navigate to the main Dashboard page of python app.
我想从我的.NET应用程序发布该表单,并且在成功通过身份验证之后,我应该导航到python应用程序的主仪表板页面。
Off course you can do this in .Net ,one method is by using web api , all you need to do is to create web api inside python application on which data will be posted from .net application and call that api method from .net like this method send user token and user name to api and get response as object of UsersTB. 当然,您可以在.Net中执行此操作,一种方法是使用Web api,您需要做的就是在python应用程序中创建Web api,然后将数据从.net应用程序发布到python应用程序中,然后从.net调用该api方法此方法将用户令牌和用户名发送到api,并作为UsersTB的对象获取响应。 You can read here how to create web api in python.
您可以在此处阅读如何在python中创建Web API。
private UsersTB getuserDateByUserNameApi(string username, int userTypeId, string token)
{
string baseUri ="Url address of python application";
try
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri(baseUri);//baseUri
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
//httpClient.Timeout = TimeSpan.FromSeconds(30.0);
var response = httpClient.GetStringAsync(string.Format("api/client/getuserDateByUsername/{0}/{1}/{2}", username, userTypeId, WebSiteID)).Result;
return JsonConvert.DeserializeObject<UsersTB>(response.ToString());
}
}
catch (Exception exp)
{
return null;
}
} //api get
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.