ASP.NET - Send Information to Website - asp.net

I have an asp.net webpage that only contains a textbox and a button. The user submits their email address using this webpage.
What I am trying to do now is take the information submitted by the user and go to another website. Where my "website/program" gives the different website the entered email address, and clicks the submit button.
If I where to physically go to the different website, there would be a textbox to enter the email. But since I am accessing the website from my page "behind the scenes" I cant manually enter their email address...
Is it possible to do this, if so how? Also, my code behind is in VB.
Thanks!

Well it can be done, but the simpllicity of it depends on what this other webpage is. Will this webpage always be the same or can it change?
If it a dynamic website that will frequently change, then you will need to basically parse the html and emulate how the email address gets posted to the webpage. Look for the tag in the html and see what page it posts to.
What you want to do is use HttpWebRequest. This class can send information to another web page. Here is a tutorial on how to do what you are asking: http://www.jigar.net/howdoi/viewhtmlcontent106.aspx
And here is the MSDN documentation on it: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.71).aspx
Keep in mind that my solution will work if the web site is using POST or GET, but some sites use Javascript. To do this, it will require you to build a javascript interpreter.

Related

Outlook/Gmail Mail Open Tracking

At the bottom of the email content i have a tiny code
img src='https://www.......aspx?Name=David' height='1' width='1'
What it does is whenever an user open the email, it tried to download the image (if email client allow) then it loads the aspx page in the background and passing Name parameter: David as GET and in that aspx page pretty much insert David into a table.
However, this seem to be working if I open outlook via browser, rather than using outlook on windows & android app and it doesn't work in gmail via browser.
How can i make it work if an user open via outlook windows/android app
Seems like it has to do with email encoding or something?
The email clients where this works are old, poorly designed, or misconfigured. The email clients where it doesn't work are smart enough to recognize this attempt at invading the user's privacy and block it, by not allowing remote images to load. There's not a way around it, and the entire point of not loading remote images is to keep people like you from doing what you're trying to do.

external POST request to update on aspx page

I am working in .net webforms and am submitting something to an external web service via .ashx which then returns a POST request with parameters to my .aspx page. I am having trouble figuring out how to get that data back on my page.
I understand that Request.QueryString["parameterName"] should get anything sent as a querystring, but how can I then take that information and, say, put it in a label on the page in my browser.
Basically I want this: user is on .aspx page, clicks a button, processing happens externally and information from the POST request from the webservice is then displayed on the screen for the user on the same .aspx page.
I assume this involves and needs some ajax - I just am not quite comfortable enough with it to know how to do it and if what I am doing is right.
Any help would be much appreciated!
thank you in advance,
syd

How can i change session when open url in another tab in asp.net

I am developing one web application in asp.net. I am opening my all pages on pop up window. I want to expire my session or change the session value when someone copy the url and paste it into another tab. How can i implement it ?
Please help me out.
A simple way would be to check Request.UrlReferrer. The Referrer would be empty if the user copy pastes a URL.
A couple of points you should consider before using this:
Provide exceptions for any pages that can be directly entered by
the user. For e.g. the login page or a page that can be bookmarked
I believe a pop can be opened from Javascript, without a referrer. Make sure your existing code is not using this method to open a pop up.
For a generic way to determine if the user has opened a new tab, see here
I have solved this problem by using this
string referer = Request.ServerVariables["HTTP_REFERER"];
if (string.IsNullOrEmpty(referer))
{
Response.Redirect("../Index.htm");
}

Legitamate cross site communication

I am building a website, within a large intranet, that wraps and adds functionality to another site within the same intranet. I do not have access to the other site's source and they do not provide any api's for the functionality they provide. I need to, somehow, have my server-side code go to that site, fill in some forms, then press a submit button.
Is this possible? If so, how can I accomplish this?
Note: I am working in asp.NET if that matters at all.
Not the most efficient, but maybe WatiN can get you started:
http://watin.sourceforge.net/
Just look at the URL the form is supposed to submit to and the method it employs (POST or GET) and then send a request to that URL using the same method and put the field you want as parameters
Your server-side code is basically a web client to the other web site. You will need to write the code to send the HTML form data to the other web site and process the response. I would start with the System.Net.WebClient class. Take a look at System.Net.WebClient.UploadValues. That class/method will enable you to POST the form data to the web site via a NameValueCollection.

File Uploading without page refresh in Web pages

Hii,
Any one knows how to upload files to the physical location of the server. It is possible using file upload control that i know. But i want to avoid the external postbacking of the page. For e.g exactly like what in the yahoo mail did.
In yahoo mail latest version if you attach a file that won't post back and attach that file in to server. What is the technology behind that?
Normally when you submit a form it does a POST request to the server, causing a refresh. Ajax requests get round this by using JavaScript to send the POST data through to the server, and that doesn't need a page refresh.
Ajax requests can't be used to send file data though, so the best way to currently do it is with an iframe hack - you use JavaScript to dynamically build up a form within an iframe, submit that form via JavaScript, and listen for the iframe's onload event. So you know when the form has been submitted. A version of this approach is detailed here:
http://www.webtoolkit.info/ajax-file-upload.html
Other methods to do this would include using a Flash-based solution like http://www.swfupload.org/ or a wrapper like http://www.plupload.com/ - these will prevent you having to roll your own solution and will also provide some extra functionality - upload progress feedback, for example.

Resources