I have a website built in ASP.NET 4.0 and currently I have a drop down box with URLs, a button that goes to that URL and parses out text and then finally a results box with the parsed text.
What I want to do is instead of going to my website and choosing the URL in the drop down box, I want to pass on the parameter as a full URL and have the button go to that and then do its thing. Kind of like a permanent link that I can hand to a user
For instance:
http://localhost:62554/WebSite5/Default.aspx –> http://google.com
google.com gets put into a variable (lets say its MyURL) and the button takes it just like if it were in the drop down box.
**Updated code: Now getting a error 500 at
using (StreamReader objReader = new StreamReader(objRequest.GetResponse().GetResponseStream()))
string newURL;
String url;
protected void Page_Load(object sender, EventArgs e)
{
//Request.Params.Get("newURL").ToString();
//string url = Request["newURL"];
//url = Request.QueryString["newURL"].ToString();
url = Request.QueryString["newURL"].ToString();
parseButton_Click(sender, e);
}
protected void parseButton_Click(object sender, EventArgs e)
{
//MyURL = deviceCombo.Text;
//MyURL = Request.Params.Get("");
//MyURL = Request.Params.Get("newURL");
//MyURL = newURL;
//string MyURL = Request.Params["newURL"].ToString();
WebRequest objRequest = HttpWebRequest.Create(url);
objRequest.Credentials = CredentialCache.DefaultCredentials;
using (StreamReader objReader = new StreamReader(objRequest.GetResponse().GetResponseStream()))
{
originalText.Text = objReader.ReadToEnd();
}
//Read all lines of file
String[] crString = { "<BR> " };
String[] aLines = originalText.Text.Split(crString, StringSplitOptions.RemoveEmptyEntries);
String noHtml = String.Empty;
for (int x = 0; x < aLines.Length; x++)
{
if (aLines[x].Contains(filterCombo.SelectedValue))
{
noHtml += (RemoveHTML(aLines[x]) + "\r\n");
}
}
//Print results to textbox
resultsBox.Text = String.Join(Environment.NewLine, noHtml);
}
Any ideas? Thank you
You can get the URL variable from the Request object.
Put this wherever you like such as Page_Load