简体   繁体   English

我可以从.NET Web应用程序将数据(用户名和密码)发布到另一个网站以进行登录吗?

[英]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.

相关问题 如何获取运行我的Web应用程序的用户的Windows登录用户名? - How do I get the windows login username of a user running my web application? 我的网站与另一个需要用户名和密码的网站之间的链接 - link between my website to another website that demands username and password 如何验证登录页面的 websql 数据库中是否存在用户名和密码? - how can i verify if the username and password exists in my websql database for login page? 我无法从我网站上的Facebook登录名获取电子邮件范围 - I can't get the email scope from facebook login on my website to work 如何不使用POST或GET输入用户名和密码输出到MySQL服务器 - How Can I Enter Username And Password Outputs To A MySQL Server Without Using POST or GET 如何从 FormData() 访问我的数据(用户名、密码等;)到我的快速服务器 - How to get access my data (username, password etc;) from FormData() into my express server 需要检查登录用户名和密码,然后从以前的条目中获取数据 - Need to check for login username and password, and then bring data from previous entries 这甚至可行吗?:用户单击我网站上的按钮 -&gt; 从另一个网站获取数据 -&gt; 在我的网站上显示此数据 - Is that even feasable?: user click on a button on my website -> get data from another website -> display this data on my website 检查登录用户名和密码,然后从以前的每个条目中获取数据 - Check for login username and password, and then bring data from every previous entry 仅当使用jquery未正确输入用户名或密码时,如何显示错误消息? - How can I get my error messages to display only if username or password is not entered correctly using jquery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM