Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default HttpContext

    Hello,

    i searched 2days for a solution and maybe someone can help me.

    I'm programmin' a C# Assemblie and don't know which class I should use
    for a WebRequest where I can hold the connection like in the
    InternetExplorer.

    I connect to [url]http://www.mypage.com:7070/main?name=myname&pass=mypass[/url]

    with HttpWebResponse and GetResponse or with a WebClient. Both ways
    deliver me the right page. I'm logged in!

    Now I want to get the [url]http://www.mypage.com:7070/topframe[/url] page but I'm
    no longer logged in. How can I hold the connection? I tried with
    System.Web.HttpContext, WebClient or
    [url]http://www.mypage.com:7070/topframe?name=myname&pass=mypass[/url] and
    searched the hole Web for information...

    Does the HttpContext work in C# programs?

    How does the IE handel this? i hope some on got an idea or know where
    i can find informations.

    MM
    Martin Madreza Guest

  2. Similar Questions and Discussions

    1. using HttpContext Class
      I'm trying to get the PathInfo propert for the current URL request in a class file, but I can't get it to work. Here's what I've tried so far: ...
    2. httpcontext HELP
      The issue is that I want to maintain the login without asking the user to login back to the application in case the session times out.....and how do...
    3. HttpContext items and one-way methods
      Hi, I try to put some custom objects into HttpContext.Current.Items collection in one-way webmethod, but they seem not to be there in another...
    4. HttpContext.Current
      Now how in the wolrd does that work? How does it know that some static method I called on some library was called by a page that had that context?...
    5. Questions on HttpContext
      Hello ALL! It is known that there's a HttpContext class in dotnet framework which provides variable sharing. I have two questions that i can...
  3. #2

    Default Re: HttpContext

    Hi Martin,

    The response from
    [url]http://www.mypage.com:7070/main?name=myname&pass=mypass[/url] likely includes
    some authentication token, such as an authentication cookie or a
    redirect to a URL with a querystring token.

    I would examine intializing the HttpWebClient.CookieContainer property,
    so that your client receives and maintains the state of cookies when
    communicating with the remote web app.

    Try the C# code below.

    Hope it helps,
    Steve


    using System;
    using System.IO; // Stream
    using System.Net; /* Uri, HttpWebRequest, HttpWebResponse, Uri
    WebException */

    namespace Sample
    {

    class WebExample
    {
    static int Main()
    {
    Uri loginUri = new
    Uri("http://www.mypage.com:7070/main?name=myname&pass=mypass");
    Uri contentUri = new Uri("http://www.mypage.com:7070/topframe");
    CookieContainer cookies = new CookieContainer();
    HttpWebRequest request;
    HttpWebResponse response;
    Stream responseStream;

    try
    {
    request = (HttpWebRequest)WebRequest.Create(loginUri);
    request.CookieContainer = cookies;
    response = (HttpWebResponse)request.GetResponse();
    Console.WriteLine("HTTP {0:D} {1}", response.StatusCode,
    response.ResponseUri);

    request = (HttpWebRequest)WebRequest.Create(contentUri );
    request.CookieContainer = cookies;
    response = (HttpWebResponse)request.GetResponse();
    responseStream = response.GetResponseStream();

    Console.WriteLine("HTTP {0:D} {1}", response.StatusCode,
    response.ResponseUri);

    // read responseStream
    responseStream.Close();
    }
    catch(WebException ex)
    {
    // handle exception here
    Console.WriteLine("Exception: {0}", ex.ToString());
    }

    return 0;
    }
    }

    }


    Martin Madreza wrote:
    > Hello,
    >
    > i searched 2days for a solution and maybe someone can help me.
    >
    > I'm programmin' a C# Assemblie and don't know which class I should use
    > for a WebRequest where I can hold the connection like in the
    > InternetExplorer.
    >
    > I connect to [url]http://www.mypage.com:7070/main?name=myname&pass=mypass[/url]
    >
    > with HttpWebResponse and GetResponse or with a WebClient. Both ways
    > deliver me the right page. I'm logged in!
    >
    > Now I want to get the [url]http://www.mypage.com:7070/topframe[/url] page but I'm
    > no longer logged in. How can I hold the connection? I tried with
    > System.Web.HttpContext, WebClient or
    > [url]http://www.mypage.com:7070/topframe?name=myname&pass=mypass[/url] and
    > searched the hole Web for information...
    >
    > Does the HttpContext work in C# programs?
    >
    > How does the IE handel this? i hope some on got an idea or know where
    > i can find informations.
    >
    > MM
    Steve Jansen Guest

  4. #3

    Default Re: HttpContext

    it works!!!

    great - many thanks

    MM
    Martin Madreza Guest

  5. #4

    Default httpcontext

    How to maintain user authentication/authorization if session times out?
    Mithun Guest

  6. #5

    Default Re: httpcontext

    Not sure what's the question, if you use form authentication, it should
    automatically redirect to login page.

    "Mithun" <mithun_babu@hotmail.com> wrote in message
    news:9D93362A-CB08-444D-A964-14525A133284@microsoft.com...
    > How to maintain user authentication/authorization if session times out?

    Beginner Guest

  7. #6

    Default Re: httpcontext

    The issue is that I want to maintain the login without asking the user to login back to the application in case the session times out..that too how do i do it using http context?
    Mithun Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139