I'm trying to create an simple website to get info from another website with username and password. This is my first time programming but I couldn't find an solution to my problem. I'm trying to have an textbox on my website with a button so when you type in f. ex username and click on button, it will send WebRequest and get information from that website:
Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
WebRequest request = (WebRequest)WebRequest.Create("https://hub.tec.net/Custom/SP/MSKR/hubtest1?userid=" + TextBox1.Text);
request.Credentials = new System.Net.NetworkCredential("myuser", "tPeVo4O5Ph13VbdVoFNIlTZvKND2Ax65");
WebResponse response = request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string html = sr.ReadToEnd();
sr.Close();
response.Close();
if (html != string.Empty && html != null)
{
Literal1.Text = html;
}
}
I don'tknow how to accomplish that. I have an button "Button1" but i don't know how to first type some text in textbox, click on that button and after that, send an WebRequest and get information from that website.
Thanks for all information and help!