-
Jul 5th, 2012, 09:53 PM
#1
Thread Starter
Addicted Member
Post url
Hello There,
I have this code in my window application. i want to create the receiving web page using asp.net. i have example but it is written in php so i dont quite get it.. please guide me on this..
thank you..
Code:
private void SubmitData()
{
try
{
String user = textBox1.Text;
string pass = textBox2.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "user" + user + "&pass=" + pass;
byte[] data = encoding.GetBytes(postData);
WebRequest request = WebRequest.Create("http://localhost/myreports/webpages/postpage.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
}
-
Jul 17th, 2012, 08:19 AM
#2
Fanatic Member
Re: Post url
What do you want the receiving page to do?
Do you know how to write an aspx page?
Have you attempted to write the page?
Do you have more code sample?
-
Jul 17th, 2012, 08:18 PM
#3
Thread Starter
Addicted Member
Re: Post url
Hi davebat,
I want the receiving page to validate the username and password pass by client application. and if success then i will redirect it to the main page. is this possible? or the client application should call my aspx page?
thank you
-
Jul 18th, 2012, 01:01 AM
#4
Re: Post url
Hello,
Ok, just so we are clear, can you perhaps provide some more information...
For instance, are you hosting this web page within your Windows Form application, and on clicking the button you want to post the login information to the Web Browser control within your application?
Or, are you looking to "automate" an Internet Explorer instance from your Windows Form application, post the login information, and then navigate to the home page?
There are a couple intricacies that you are going to have to think about before implementing this, but it would be good to know exactly what you are trying to achieve before sending you off on the wrong path.
Gary
-
Jul 18th, 2012, 03:25 AM
#5
Thread Starter
Addicted Member
Re: Post url
Originally Posted by gep13
Hello,
Or, are you looking to "automate" an Internet Explorer instance from your Windows Form application, post the login information, and then navigate to the home page?
Gary
This is what i want to achieve gary.
-
Jul 18th, 2012, 06:51 AM
#6
Re: Post url
Hello,
Ok, can I ask why you want to do this, before we go to much further?
Gary
-
Jul 18th, 2012, 08:33 AM
#7
Fanatic Member
Re: Post url
Hi GJA
Yes this is certainly possible, it would be sueful if you could answer Geps questiosn first tho mate
-
Jul 18th, 2012, 07:03 PM
#8
Thread Starter
Addicted Member
Re: Post url
Hi geps,
This is the requirements of my project i want to integrate my webpage into my windows application. lets say i want to click a button "log in to my website" in my windows app. it will open a browser and redirect to my home page..but windows app. should pass username and password in order to login my website..
thank you!
-
Jul 18th, 2012, 08:55 PM
#9
Re: Post url
It sounds like you've never built/deployed a asp.net website is this the case?
It also sounds like an internet (external server) NOT intranet (local server) website is this the case?
A website using asp.net forms authentication can take the posted credentials, authenticate the user and maintain security over protected resources/pages. User credentials are normally stored in a database (sql server) but can be held in the web.config file. There are lots of tutorials and examples on doing this it just depends on your experience.
The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.
-
Jul 19th, 2012, 12:42 AM
#10
Re: Post url
Hello,
There are a couple articles out there that will likely help you out with this:
http://www.codeproject.com/Articles/...ernet-Explorer
http://support.microsoft.com/kb/311293
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|