Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:28:43+00:00 2026-06-17T08:28:43+00:00

I am trying to authenticate a HttpWebRequest . My code is like this string

  • 0

I am trying to authenticate a HttpWebRequest. My code is like this

 string url = "http://mydomain.com";
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
    req.Headers[HttpRequestHeader.Cookie] = string.Format("{0}={1}", cookie.Name, cookie.Value);
    WebResponse res = req.GetResponse();

Everything goes fine till last line executes(WebResponse res = req.GetResponse();).When last line executes code execution goes back to first line(string url = “string url = “http://mydomain.com”;”;) and start again,this happens so many times that a time out exception happens.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:28:44+00:00Added an answer on June 17, 2026 at 8:28 am

    First – not clear why url is defined like this:

    string url = "HttpContext.Current.Request.Url.AbsoluteUri";
    

    This is not a valid URL. But if you have

    string url = HttpContext.Current.Request.Url.AbsoluteUri;
    

    Than you are producing a request to that same page you are in. So basically, you simply produce a loop. You call your page from a browser, it calls itself using webrequest, and it calls itself again. So in VS debugger will show you like it goes back to the first line.
    Try simply change url definition like below:

    string url = "http://wwww.google.com";
    

    If you will do that,it should work fine. Basically, as I understand, you are simply using wrong URL which creates something like a loop (or even better to say: long chain of calls)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code is like this Doc doc = new Doc(); string url = HttpContext.Current.Request.Url.AbsoluteUri;
I am trying to authenticate user using LDAP I am using this code: public
Iam trying to authenticate to https url , but iam getting exception . Below
I'm trying to authenticate user accounts in Windows Phone. I found this C# library
I am trying to authenticate into JBoss, and I got HTTP Status 408 -
I am trying to authenticate to a server's secure URL using java.net.urlconnection - based
Update: This issue has been resolved. I was trying to authenticate various admin accounts
I am trying to authenticate against google, and this is their example request: POST
I am trying to authenticate a GKLocalPlayer with Game Center. However, the code supplied
I'm trying to create an ASP.Net MVC endpoint to authenticate externally. The idea is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.