473,670 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application that gets URLs with the default browser credentials

dk9
The Situation:
I'm working in my browser at a secured site (https).
At the same time I need my application to get and parse some urls from
that same site.

What I've tried:
I've login with my browser, but when trying to get the pages using
WebRequest from my application I can only get the "you need to login
page".
I've then put a WebBrowser control in my application and do the login
from there. I can get the urls and navigate the site but I cannot
fully work from there because I need pop-ups pages, and those are
opened in the default browser (in these case showing the "you need to
login page").

My Questions:
What approches can I make from here?
What shall I use so my application have the same credentials of my
browser or vice-versa?
Webbrowser, WebRequest, WebClient??? any other?
Many Thanks for any help

Aug 16 '07 #1
4 2460
dk9
Resolved using two WebBrowser controls and opening the pop-ups pages
in the second WebBrowser
Aug 22 '07 #2
Sorry, I never saw your original post. You can also get the cookies from the
installed browser and use those. It would assume they've already
authenticated through the browser and that the cookies are still valid.

I have a small library on SourceForge for reading cookie files from IE and
Firefox:
http://ncookiereader.sourceforge.net/
"dk9" <dk*****@gmail. comwrote in message
news:11******** *************@g 4g2000hsf.googl egroups.com...
The Situation:
I'm working in my browser at a secured site (https).
At the same time I need my application to get and parse some urls from
that same site.

What I've tried:
I've login with my browser, but when trying to get the pages using
WebRequest from my application I can only get the "you need to login
page".
I've then put a WebBrowser control in my application and do the login
from there. I can get the urls and navigate the site but I cannot
fully work from there because I need pop-ups pages, and those are
opened in the default browser (in these case showing the "you need to
login page").

My Questions:
What approches can I make from here?
What shall I use so my application have the same credentials of my
browser or vice-versa?
Webbrowser, WebRequest, WebClient??? any other?
Many Thanks for any help

Aug 22 '07 #3

On Aug 22, 2:52 pm, "pedrito" <pixbypedrito at yahoo.comwrote:
I have a small library on SourceForge for reading cookie files from IE and
Firefox:http://ncookiereader.sourceforge.net/
throw new NotImplementedE xception("No support for finding the cookie path yet.");
For what it's worth, here's what I did once to find the Firefox cookie
path (using the default profile of the current user):

private const string PATH_PROFILES_I NI = @"%APPDATA%\Moz illa\Firefox
\profiles.ini";
private const string PATH_COOKIES_TX T = @"%APPDATA%\Moz illa\Firefox\
%PROFILE%\cooki es.txt";
....
string pathAppData =
Environment.Get EnvironmentVari able("APPDATA") ;
string profilesIniPath = PATH_PROFILES_I NI.Replace("%AP PDATA%",
pathAppData);
string profileDir = null;
// Find default profile in profiles.ini
Dictionary<stri ng, string>[] firefoxProfiles Ini =
ParseIniFile(pr ofilesIniPath);
foreach (Dictionary<str ing, stringiniGroup in
firefoxProfiles Ini) {
if (iniGroup.Conta insKey("Default ") && iniGroup["Default"] ==
"1")
profileDir = iniGroup["Path"];
}
_cookiePath = PATH_COOKIES_TX T.Replace("%PRO FILE%",
profileDir).Rep lace("%APPDATA% ", pathAppData);
....
const string INI_PATTERN = @"\s*\[([^\]]*)\]\r?\n([^\[]*)";
public static Dictionary<stri ng, string>[] ParseIniFile(st ring
IniFilePath) {
List<Dictionary <string, string>dictList = new
List<Dictionary <string, string>>();
string iniContents = File.ReadAllTex t(IniFilePath);
MatchCollection mc = Regex.Matches(i niContents, INI_PATTERN,
RegexOptions.Si ngleline);
foreach (Match m in mc) {
Dictionary<stri ng, stringdict = new Dictionary<stri ng,
string>();
string iniGroupName = m.Groups[1].Value.Trim();
dict.Add("_name ", iniGroupName);
string[] newlines = { "\n", "\r", "\r\n" };
foreach (string keyvalue in m.Groups[2].Value.Split(ne wlines,
StringSplitOpti ons.RemoveEmpty Entries)) {
if (keyvalue.Conta ins("=")) {
dict.Add(keyval ue.Split('=')[0].Trim(),
keyvalue.Split( '=')[1].Trim());
}
}
dictList.Add(di ct);
}
return dictList.ToArra y();
}

Aug 22 '07 #4
"UL-Tomten" <to****@gmail.c omwrote in message
news:11******** *************@l 22g2000prc.goog legroups.com...
>
On Aug 22, 2:52 pm, "pedrito" <pixbypedrito at yahoo.comwrote:
>I have a small library on SourceForge for reading cookie files from IE
and
Firefox:http://ncookiereader.sourceforge.net/
>throw new NotImplementedE xception("No support for finding the cookie path
yet.");

For what it's worth, here's what I did once to find the Firefox cookie
path (using the default profile of the current user):

private const string PATH_PROFILES_I NI = @"%APPDATA%\Moz illa\Firefox
\profiles.ini";
private const string PATH_COOKIES_TX T = @"%APPDATA%\Moz illa\Firefox\
%PROFILE%\cooki es.txt";
...
string pathAppData =
Environment.Get EnvironmentVari able("APPDATA") ;
string profilesIniPath = PATH_PROFILES_I NI.Replace("%AP PDATA%",
pathAppData);
string profileDir = null;
// Find default profile in profiles.ini
Dictionary<stri ng, string>[] firefoxProfiles Ini =
ParseIniFile(pr ofilesIniPath);
foreach (Dictionary<str ing, stringiniGroup in
firefoxProfiles Ini) {
if (iniGroup.Conta insKey("Default ") && iniGroup["Default"] ==
"1")
profileDir = iniGroup["Path"];
}
_cookiePath = PATH_COOKIES_TX T.Replace("%PRO FILE%",
profileDir).Rep lace("%APPDATA% ", pathAppData);
...
const string INI_PATTERN = @"\s*\[([^\]]*)\]\r?\n([^\[]*)";
public static Dictionary<stri ng, string>[] ParseIniFile(st ring
IniFilePath) {
List<Dictionary <string, string>dictList = new
List<Dictionary <string, string>>();
string iniContents = File.ReadAllTex t(IniFilePath);
MatchCollection mc = Regex.Matches(i niContents, INI_PATTERN,
RegexOptions.Si ngleline);
foreach (Match m in mc) {
Dictionary<stri ng, stringdict = new Dictionary<stri ng,
string>();
string iniGroupName = m.Groups[1].Value.Trim();
dict.Add("_name ", iniGroupName);
string[] newlines = { "\n", "\r", "\r\n" };
foreach (string keyvalue in m.Groups[2].Value.Split(ne wlines,
StringSplitOpti ons.RemoveEmpty Entries)) {
if (keyvalue.Conta ins("=")) {
dict.Add(keyval ue.Split('=')[0].Trim(),
keyvalue.Split( '=')[1].Trim());
}
}
dictList.Add(di ct);
}
return dictList.ToArra y();
}
Thanks. I actually know how to do it, just haven't had time to implement it
yet. I have another project that's consumed most of my free time lately.
nCookieReader was a library I originally created as part of the other
project, but thought others might find it useful. The other app is launched
from the browser and the cookie path for firefox is passed as a parameter,
so that's why I didn't bother implementing it at the time. I plan to add it,
however, when I get free time... Somewhere between this other app, work,
school and research.
Aug 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
2931
by: AES/newspost | last post by:
My understanding -- I'm not an expert -- is that on (some? many? all?) standard Internet servers a URL can point to a subdirectory name followed by a backslash, and that links to this URL will automatically go to an "index.html" file located in that subdirectory, if there is one. Q1: Is this more or less correct? At least some HTML texts also recommend using this as the basis for organizing a web site: Put the web pages associated...
0
2921
by: Cenray | last post by:
How to generate a web request from a Winform Application using a WebService? In a C# Windows Application, when I try to genrate a web request using the following code, it is woking fine Winform code --------------- Browser.DocumentHTML = ""; string HTMLData="";
6
2393
by: Erez Shor | last post by:
Hi, I need to build and asp page which access a remote windows server's registry and create a registry key. In order for the ASP page to be able to access the registry on the remote server I need it to run using credentials supplied by the user. When using basic authentication this is not an issue since the user has to provide a user name and password. But I don't want to use basic authentication so I created a login form and I am using...
4
1951
by: moondaddy | last post by:
I've made the decision to use search engine friendly URLs in my site which means translating stripping all parameters our of the URL and converting it to a hierarchical URL like this: Change: /mysite/default.aspx?MenuID=contactus To: /mysite/ContactUs.aspx? The problem I'm having is that its really slowed things up by at least 0.5 seconds to 1 second longer just to pull up a light weight static page. The
20
6592
by: Keith G. Murphy | last post by:
I'm trying to get a feel for what most people are doing or consider best practice. Given a mod_perl application talking to a PostgreSQL database on the same host, where different users are logging onto the web server using LDAP for authentication, do most people 1) have the web server connecting to the database using its own user account (possibly through ident), and controlling access to different database entities strictly through...
7
2231
by: Victor | last post by:
I've got two domain names sharing the same IP address that use ASP VBScript If I set a session variable with domain 1, it is only available for domain 1 - this is correct? If I set an application variable with domain 1, the app variable is sharing across all domains using that IP address - this is correct? This is the behavior I am seeing and I want to make sure that my server is set up correct. I especially want to make sure...
1
6476
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config <authentication mode="Windows" /> and set up IIS to not allow anonymous access. My browser is set up to auto detect the proxy server, so IE/Firefox can access outside pages, so I added code to auto-detect the proxy server.
1
3063
by: xcelmind | last post by:
Hello Dev. Guru, I want to at this time introduce myself. I am Stanley Ojadovwa by name. I知 a freelance and a newbie in web application development. I知 currently using ASP as my application server technology with Microsoft access as my database source. Just as I have introduced myself, I知 a newbie in web application development. I知 currently working on an application that will allow
1
4893
by: Brian McCullough | last post by:
Hello, I am running Windows XP (SP2 and all recent updates) on my development box. When I have Anonymous Access on my Virtual Directory, I can navigate to my "web site" fine. I setup my ASP.NET 2.0 application's Virtual Directory to "Integrated Windows authentication" only (unchecked the Anonymous Access) and now I keep getting prompted for credentials every time I try to hit my site. I am trying to hit it from outside the IDE using...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project用lanning, coding, testing, and deployment謡ithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.