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

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

Trying To Automatically Authenticate basic HTTP using VB .NET

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :.NET Framework


I am trying to create a program which interfaces with a HTTP page which needs basic authentication. I have created the basic web browser controls etc but have not been able to get the authentication working.

I have the idea that I could "handshake" with the site first before entering the username and password as an ICredential. Does this sound possible? The code I have is below:

Dim request As System.Net.HttpWebRequest
request = System.Net.HttpWebRequest.Create(WebAddress)
request.Credentials = (New System.Net.NetworkCredential("username", "password"))


The above doesn't seem to work, giving me a 401 error and URL malformed exception. ( My url is an IP address eg )


Does anyone have any idea how to do this? Help! :)

View Complete Post

More Related Resource Links

Trying to get basic Http URL with querystring parameters processed in WCF service

I'm trying to process a post by a third party server (Paypal) processed by my server through a WCF service. All I need is to get and process the values with the query string. This sounds incredibly easy, but after a weekend, I'm still stumped.  Any help would be greatly appreciated. Passing the following URL from my browser to the service causes a AddressFilter mismatch fault (below). http://localhost:9409/PPInfo.svc/ReadResponse?RESULT=0&AUTHCODE=10001&RESPMSG=APROVED&PNREF=12345 produces <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> - <Code>   <Value>Sender</Value> - <Subcode>   <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value>   </Subcode>   </Code> - <Reason>   <Text xml:lang="en-US">The message with To 'http://localhost:9409/PPInfo.svc/ReadResponse?RESULT=0&AUTHCODE=10001&RESPMSG=APROVED&PNREF=12345' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text>   </Reason>   </Fault> // web.config  <system.serviceModel>     <behaviors>       <servic

Basic Authentication => http://MainSiteUsername@MainSitePassword@sitename.com

Hi,We have an Main asp.net site and Help site which is a plain html protected by 'Basic Authentication'.The requirement is once you already login on the Main asp.net site,  there is a link "Help" which is calling http://MainSiteUsername@MainSitePassword@companyhelp.com this was working well till this KB834489 came in.Can you help us solve this issue? Same issue with this one:http://www.bigresource.com/Tracker/Track-asp-D5uQcKze/Hope someone could help me on this.br,Chris

How to authenticate automatically to the external portal from Page viewer?

Page viewer web part gives iView to the website eg. http://www.test.com. This works fine! Our customer would like login to the external portal with attaching user name in the ur like http://www.test.com/abc?name=John. Or user single sign on to login to the external portal. Authentication to the external system should be automatical to the end-user so that they don't have to login manually to the www.test.com portal. How to do it?Kenny_I

Sesame: Spatial OData on Maps, Service Operations, HTTP Basic Authentication

Sesame Data Browser has just been updated to offer the following features for OData feeds: MapsImproved Service operations (FunctionImport) supportHTTP Basic Authentication supportMicrosoft Dallas support Maps Sesame now automatically displays items on a map if spatial information is available in data.This works when latitude and longitude pairs are provided.Here is for example a map of drinking fountains in Vancouver:This comes from DrinkingFountains in http://vancouverdataservice.cloudapp.net/v1/vancouver, which provides latitude/longitude for each fountain. Here is another example, without latitude/longitude this time: This is a map of the customers from the Northwind database, which are located based on their country, postal code, city, and street address. Service operations (FunctionImport) Support for service operations (aka FunctionImports) has been improved. Until now, only functions without parameters were supported. It's now possible to use service operations that take input parameters. Let's take as an example the GetProductsByRating function from http://services.odata.org/OData/OData.svc.This function is attached to Products, as you can see below: A "rating" parameter is expected in order to open the function: After clicking Open, you'll get data as usual:HTTP Basic Authentication New authentication options have been added: HTTP Basic and Dallas (more

WCF Basic Http Binding - Two server requests per method call

We have a service that uses BasicHttpBinding/Transport Security/Windows Authentication and is hosted in IIS. I have created a unit-test application in VSTS and whenever we test a WCF method, Fiddler records two calls. 1st call - No authorization token is sent. The WCF service returns a 401 error - Unauthorized: Access is denied. Http headers as sent in the request given below. POST http://localhost/AccountScreen.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "IAccountScreen/RetrieveAccountDetails" Host: localhost Content-Length: 243 Expect: 100-continue Connection: Keep-Alive 2nd call - Authorization token is sent and the WCF service returns the expected response. POST http://localhost/AccountScreen.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "IAccountScreen/RetrieveAccountDetails" Authorization: Negotiate Host: localhost Content-Length: 243 Expect: 100-continue I am not able to figure out why there are two calls made to the server in the first place and what is the significance of the first call. Any thoughts?

How to automatically Authenticate User on External Site once Authenticated on SharePoint Site


We analyzing the implementations approach, for a scenario.

  1. External Site: To log-in to external site which has its own user store and is hosted on different domain. So user has to provide his user id and password for logging in to external site like e.g.  DOMAIN1\UserName & Password

  1. SharePoint Site: This site is hosted on different domain other than DOMAIN1 and has got windows/forms authentication. So the user to login to SharePoint site has to provide SharePoint site Credentials DOMAIN2\UserName & Password.
  2. SharePoint Web Part which shows external site in IFrame and allows user to perform CURD operation once the user is authenticated in external site.

What we want is once user login to SharePoint site using (Forms/Windows) authentication, he should be automatically authenticated in External Site (using some mechanism) the logged in user credentials are picked up from some store based on his sharepoint username and system authenticates the user on external site.

Any pointers to code/blogs/articles would be really helpful.

Akhilesh Nirapure

Use HTTP Basic Auth and ASP.NET Membership Provider with WCF DataService


I have a WCF Data Service (inherits System.Data.Services.DataService<T>) that I need to secure using HTTP Basic Authentication. I also want to use the ASP.NET Membership Provider for validating username/password.

I've searched quite a bit online on how to do this. The only thing I found that'll work is to write a custom HttpModule to handle the HTTP Basic authentication.

There must be a way to configure WCF with a DataService<T> to use HTTP Basic Authentication with the ASP.NET Membership Provider. Does anyone know how to do this?

I also wouldn't be apposed to using OAuth 2.0 for authentication, but it still needs to use the ASP.NET Membership Provider.


Microsoft MVP - Windows Live Platform
Blog: http://pietschsoft.com  | Web.Maps.VE - ASP.NET AJAX Bing Maps Server Control

How do I get the userName and passWord sent by a client using http basic authentication in a wcf se


Hello Guys,

I need to get the username and password that my java clients are passing using basic http authentication.

The message my clients are sending is the following:

POST http://localhost:1715/PanelService.svc/PanelService HTTP/1.1<br/>
Accept-Encoding: gzip,deflate<br/>
Content-Type: text/xml;charset=UTF-8<br/>
SOAPAction: "http://br/com/petrobras/operational/services/PanelService/getAverageByBusinessObject"<br/>
Authorization: Basic YWJjZGVmOjEyMzQ1Ng==<br/>
User-Agent: Jakarta Commons-HttpClient/3.1<br/>
Host: localhost:1715<br/>

OleDB OLAP provider, http and basic authentication


I am using OLAP OleDB provider (or ADOMD.NET - doesn't make difference) to connect to SSAS through HTTP. IIS is configured to accept on Basic Authentication.

The thing works, but there is a problem. Every request issued by OleDB provider first tries anonymous authentication and only when it is rejected it goes with basic authentication. So it works, but every request is composed of at least two roundtrips.

Any idea how to persuade OleDB client to use basic authentication from start?

Miha Markic [MVP C#] http://blog.rthand.com

WCF Tutorial - Basic Interprocess Communication

What the heck is WCF? For a long time, I couldn't tell you exactly what it was. And honestly, I still don't think I can. WCF is such a broad concept that it's hard to boil down into a concise explanation. When I finally started reading about it, and getting beyond the concepts, things started to clear up. That's what today's tutorial is about - cutting through all the concepts and just use WCF to build a basic server and a basic client.

ASP.NET Architecture - ASP.NET Worker Process - HTTP Pipleline - Http Modules and Handlers

"ASP.NET is a powerful platform for building Web applications, that provides a tremendous amount of flexibility and power for building just about any kind of Web application. Most people are familiar only with the high level frameworks like WebForms and WebServices which sit at the very top level of the ASP.NET hierarchy. In this article I'll describe the lower level aspects of ASP.NET and explain how requests move from Web Server to the ASP.NET runtime and then through the ASP.NET Http Pipeline to process requests.

How to run Office macros by using Automation from Visual Basic .NET

This step-by-step article describes how to call Office macros from a Visual Basic .NET Automation client.

You can use Microsoft Office Automation to open a document or create a new document that contains a Visual Basic for Applications (VBA) macro and execute the macro at run time.

learn basic about share point.

This learn basic about share point.

Dynamically Create Controls in ASP.NET with Visual Basic .NET

This step-by-step article describes how to dynamically create controls for an ASPX Web page.

The sample project does the following:
It creates two TextBox controls.
It verifies that the TextBox contents (TextBox.text) and attributes are saved across posts to the server.
It describes how events that are posted by a dynamically created control are handled.

Creating a Basic SharePoint Web Part

This programming task includes the steps for creating a basic custom Windows SharePoint Services Web Part. It is a simple Web Part that allows you to change the Web Part's Title property, which is a Windows SharePoint Services WebPart base class property that sets the text in the title bar of the Web Part.

Open File Print File Excel

Batch print many Excel files without having to open each one at a time. Quickly print mass amounts of xls files at once with this program. You must have Excel installed on your machine..

Writing Http Handlers and Modules in IIS 7.5

This article describes how Http modules and handlers are to be written and configured in IIS 7.5. The concept of a handler and module remains same, so dose there programming model. In this section we start off with the concept of a Http module and a Http handler, then talk about how to code them and finally describe the two methods available to configure them.
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