Results 1 to 10 of 10

Thread: Post url

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    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);
                }
            }

  2. #2
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    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?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    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

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: Post url

    Quote Originally Posted by gep13 View Post
    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.

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Post url

    Hello,

    Ok, can I ask why you want to do this, before we go to much further?

    Gary

  7. #7
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: Post url

    Hi GJA

    Yes this is certainly possible, it would be sueful if you could answer Geps questiosn first tho mate

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    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!

  9. #9
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    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.

  10. #10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width