.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Httpwebrequest Login - Logged's in but can it be cleaned up.

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

Hi. I can log into my site fine. But just wondered if i am doing it right. Just because some thing works does not mean it is correct.



  Dim cc As New CookieContainer
  Dim postBytes As Byte()
  Dim requestStream As Stream
  Dim pageSource As String
  Dim response As HttpWebResponse
  Dim request As HttpWebRequest = DirectCast(Net.WebRequest.Create(LoginUrl), Net.HttpWebRequest)
  Dim loginData As String = String.Format(My.Settings.HttpLoginReferer, My.Settings.UserAccountName, My.Settings.UserAccountPassword)<br/>

View Complete Post

More Related Resource Links

HttpWebRequest Form Authentication Not Getting Past Login Page

Hey Guys,I am trying to use HTTPWebRequest to login to a site and then retrieve the page after login. However, it seems as if I can't get past the login. I also investigated with Fiddler and tried mimicking Fiddler almost completely and still no luck.Any idea what I am doing wrong?Thanks,Mohammed    Dim webRequest As HttpWebRequest Dim responseReader As StreamReader Dim responseData As String Dim postData As String = "login=testexpert@yahoo.com&password=testexpert" Dim cookies As CookieContainer = New CookieContainer() Dim requestWriter As StreamWriter Try 'post form data to page strUrl = "https://www.ideeli.com/login" webRequest = HttpWebRequest.Create(strUrl) webRequest.Method = WebRequestMethods.Http.Post webRequest.ContentType = "application/x-www-form-urlencoded" webRequest.CookieContainer = cookies webRequest.ContentLength = postData.Length requestWriter = New StreamWriter(webRequest.GetRequestStream) requestWriter.Write(postData) requestWriter.Close() 'recieve cookie webRequest.GetResponse().Close() 'now we send the cookie webRequest = HttpWebRequest.Create("http://www.ideeli.com") webRequest.CookieContainer = cookies responseReader = New StreamReader(webRequest.GetResponse.GetResponseStream()) responseData = responseReader.ReadToEnd() res

Windows Security Login popup for 3 times after logged in after changed theme banner


Hi experts,

I do have problem with my SharePoint theme. I have actually create new theme by customized a theme from the default theme in SharePoint. I have replace with new banner and do some changes in the coding site.

After i have applied the theme to my portal, i face problem when i try to logged in using a username from Read Only group, it will appear the windows security login for 3 times before the portal can be access, unfortunately the banner are still not visible. Sometimes, its appear, sometime it didn't. 

However, when i logged in user System Account, i have no problem accessing the page without windows security login appear and the banner are there.

What am i missing, please do let me know. Thank you.

Cannot drop a login because the user is logged on


I want to be able to drop a login forcefully even if the login is currently logged on, its a SQL login. I have tried setting the database offline and online but that does not seem to do the trick, the way I do this is to restart the SQL service, but this often require logging onto the server to do this, I was wondering whether there are other options other than restarting the service.

If I disable the login, the login is still connected because the connection persists from the application unless SQL is restarted or unless the application is restarted.

Any ideas ?

I thought this would be simple... Trying to create a login does an ajax check before submit


I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time

logged in user data


I'm using the defualt membership provider, i created a table and used the gridview on the logged in user page to show his information such as address e-mail phone zip code etc,, how can i do this without writing a code?

I am new to asp.net  i need simple help please?

How to modify the login control



I'd like to record more information than the default control allows as well as perform actions with the input when the form is submitted but I'm having trouble figuring out how.

So firstly, if I want to record the middlename for example, how would I do that, and by default, where would it go if anywhere?
When the form is submitted, I'd like to take specific input, such as just the middlename for example, and write some linq to sql code to specify when and how it's stored.
In what event would I put this code?


create user wizard login error message dont show in a message box?




i am using create user wizard and capturing other information within content template when a new user

registers. Some of the textboxes are binded to required field validators.


there is a validation control on the page and ShowMessage box is True.

If they dont complete some of the text boxes then the message box pops Up with the error message.

It does not however include information errors like "User already exists" or Email address already exists

from the create user wizard membership  UserName and Password Textboxes


is it possilbe to hook all of these up so I get one message box with all errors including membership ones?




Using network login



Is anyone have sample code to set up log in page using network login?

For example: User Name(same as Network Login)

                     Password(Same as Network Login)

Your help is highly appreciated.



Hi All

VS2005, .Net 2.5

i have been building a website and testing it in google chrome, which has been working fine.

i am now testing it in IE and firefox and the asp:login doesnt work, it doesnt even post back when i click the 'login' button.

anyone and idea what might be going on? im not sure where to start, as i mentioned above the login works fine using google chrome.


Users getting logged out because HttpContext.Current is null


We've  been trying to fix this one for a couple years, and I'm just out of ideas, so any help is really appreciated!

We've got a fairly large, complex web application that uses Forms Authentication to authenticate users.  Throughout the application we store and retrieve information about users in the Session object, and in some cases in cookies.  In a couple places we check for the existence of the context, and if it's null we send the user back to the login page to re-establish the session. 

Just a quick run-down of this web app: C#, .NET 3.5, IIS 6, ASP.NET State Service to manage session

As for the session timer, we use our own home-grown timer, which is basically a client-side timer, which is backed up by a check to the SQL database to see when their last activity was.  This seems to work well for us.  It's not perfect, but it allows us to notify the user before the session times out, and allows us to be certain we're not logging a user out before their 60 minutes of inactivity is up.

What's happening is that certain users are being logged out after just a few minutes.  We've eliminated the timer as a cause and believe what's happening is the HttpContext.Current is null, so the user is logged out.  We do not know why the HttpContext.Current is null, and I underst

Visual Web Developer 2010 Express "Copy Web Site" using different login


I created a site and am trying to grant another pesron access to upload changes to it without giving them my super-user login.

I made a login for her but I can't test whether it works or not because no matter how much I "disconnect" in the Copy Web Site page of VWD 2010, reconnecting to the same site always logs in as my superuser account without prompting me for a login again.

How do I test is the account it set up correctly before having her try to upload to it?    I want to force the login to remote site dialog to pop up again to test her account.

Any ideas?

Fetching the Currently Logged in user Email


Hey Frnds,

I am using the System.DirectoryServices.UserPrincipal.Current.EmailAddress to fetch the Currently logged in users email from AD.

If  debug my sol am getting the Exact mail id of that Particular user for ex:john@in.domain.com.

If i host My Application on iis

And Access my App am getting some other Email id instead of the john@in.domain.com.

I have changed the Application Pool identity to NetWorkService.

Can any one tell what could be wrong






Ive 'inherited' some code that creates a HttpWebRequest object to consume a webservice and am working through it to figure out what each bit does.  Ive never consumed webservices this way before (I always create a webreference) so this way of working is new to me.  I can follow all of it except for one bit.  Heres the code Im having trouble understanding

ASCIIEncoding encoding = new ASCIIEncoding();
byte[] bytesToWrite = encoding.GetBytes("The message here");

// create web request
const string Action = "http://Awebaddress.org/AProcess"; 
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("The web service url here");

const string contentType = "text/xml; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = contentType;
httpWebRequest.Timeout = -1;
httpWebRequest.ContentLength = bytesToWrite.Length;

the line im having trouble with is this one

Login Adpater


I am having problems getting the adpaters to work.  The Whitepaper references a vsi to install but the link to download does not contain the vsi - just source for the CSSFriendly kit.  The kit is missing the css/import.css file also.

Anyway, I fumbled around and was able to get the menu working but I cannot figure out how to specify the css class for the login control.  With the CSSFriendlyAdparters.browser file in my project, I lost all styles and most of the features of the login control.  The menu uses cssselectorclass but I tried that server tag on the <asp:login> and it did not work.  The original cssclass attribute does not seem to do anything either.

Can someone point to some documentation on how to use these tags and integrate with the CSSFriendly.dll adpaters.

Thank you,


Desktop Security: Create Custom Login Experiences With Credential Providers For Windows Vista


Why is a change to the Windows logon plug-in interface so exciting? Because with credential providers you can customize the logon experience for your users.

Dan Griffin

MSDN Magazine January 2007

Login Redirection



i have creaated my own login control and my site have many pages many of pages are public to anyone but when they try to enter some section or try to send sms they be redirect to login page

my problem now after tey redirect to login page  and enter login info they redirect back to Default.aspx not the previous page they want to enter


user request page named  Page1.aspx  /page one user have to be registered so he will redirect to Login.aspx

user will enter sign in info   so he will redirect to Default.aspx /that's my problem

cause what i want to do ,that user will redirect back to Page1.aspx

how can i do this

help please


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend