hi,
i ve tried to auto login into an asp.net website. using javascript i can automatically log in to the www.irctc.co.in website but the same code have not worked for the website i ve tried. it have not even fill the username and password in the required filed. it just taken me to the login page of that website. the code i ve used is

<html>
<head>

<script type="text/javascript">

function autoLogin() {
document.webservices.submit();
} 
</script>

</head>

<a href="javascript:autoLogin()">Log me automatically in</a>

<BODY>
<form name="webservices" method=post action="https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/services/login.do" target="new_window" onSubmit="window.open('', 'new_window', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes)"> 
<input type=hidden id=UserName name="userName" value="xxxxxx"></input> 
<input type=hidden id=Password name="password" value="yyyyyy"></input> 
</form>

</body>
</html>

i dont know where i am wrong. ps correct me.

hello guys,


actually i ve got this url when i made google search for "autologin into asp.net website". i can understand the concept they ve explained. but i dont know which language they have mentioned [whether it is c# or asp.net]. and how to implement that code.
so anybody pls go through the link below.

http://www.byteblocks.com/page/How-to-submit-requests-to-web-sites-programatically-using-HttpWebRequest.aspx

it would be very helpful for my project if u go through it and explain me how and where to implement it.
expecting fast replies guys since im in urge to complete my project soon. pls..

Thanks in advance.

hey i really wondered that no body ve the knowledge in this stream to help me! y cant u help me regarding this since i need this for my project..


come on guys .... make ur reply soon..

protected void Button1_Click(object sender, EventArgs e)
    {
        CookieContainer cookies = LoginIrctc();
        //ClickFlickrButton(cookies, TextBox1.Text);  
    }
    private CookieContainer LoginIrctc()
    {
        string appURL = "https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/services/login.do";
        string strPostData = String.Format("userName={0}&password={1}",
        "XXXX", "YYYY");

        // Setup the http request.      
        HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
        HttpWebRequest;
        wrWebRequest.Method = "post";
        wrWebRequest.ContentLength = strPostData.Length;
        wrWebRequest.ContentType = "application/x-www-form-urlencoded";
        CookieContainer cookieContainer = new CookieContainer();
        wrWebRequest.CookieContainer = cookieContainer;

        // Post to the login form.      
        StreamWriter swRequestWriter = new
        StreamWriter(wrWebRequest.GetRequestStream());
        swRequestWriter.Write(strPostData);
        swRequestWriter.Close();

        // Get the response.      
        HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();

        // Read the response      
        StreamReader srResponseReader = new
        StreamReader(hwrWebResponse.GetResponseStream());
        string strResponseData = srResponseReader.ReadToEnd();
        srResponseReader.Close();

        //YOU ARE NOW LOGGED IN TO IRCTC!      
        Response.Write(strResponseData);      
        return cookieContainer;
    }











<form id="form1" runat="server">
    <div>
    
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        
    
    </div>
    </form>

we also looking same thing.

commented: No! You have to start a thread to put your problem. -3

I want same method implementation for yammer account? Any solution appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.