473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2443
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*********************@g4g2000hsf.googlegrou ps.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 NotImplementedException("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_INI = @"%APPDATA%\Mozilla\Firefox
\profiles.ini";
private const string PATH_COOKIES_TXT = @"%APPDATA%\Mozilla\Firefox\
%PROFILE%\cookies.txt";
....
string pathAppData =
Environment.GetEnvironmentVariable("APPDATA");
string profilesIniPath = PATH_PROFILES_INI.Replace("%APPDATA%",
pathAppData);
string profileDir = null;
// Find default profile in profiles.ini
Dictionary<string, string>[] firefoxProfilesIni =
ParseIniFile(profilesIniPath);
foreach (Dictionary<string, stringiniGroup in
firefoxProfilesIni) {
if (iniGroup.ContainsKey("Default") && iniGroup["Default"] ==
"1")
profileDir = iniGroup["Path"];
}
_cookiePath = PATH_COOKIES_TXT.Replace("%PROFILE%",
profileDir).Replace("%APPDATA%", pathAppData);
....
const string INI_PATTERN = @"\s*\[([^\]]*)\]\r?\n([^\[]*)";
public static Dictionary<string, string>[] ParseIniFile(string
IniFilePath) {
List<Dictionary<string, string>dictList = new
List<Dictionary<string, string>>();
string iniContents = File.ReadAllText(IniFilePath);
MatchCollection mc = Regex.Matches(iniContents, INI_PATTERN,
RegexOptions.Singleline);
foreach (Match m in mc) {
Dictionary<string, stringdict = new Dictionary<string,
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(newlines,
StringSplitOptions.RemoveEmptyEntries)) {
if (keyvalue.Contains("=")) {
dict.Add(keyvalue.Split('=')[0].Trim(),
keyvalue.Split('=')[1].Trim());
}
}
dictList.Add(dict);
}
return dictList.ToArray();
}

Aug 22 '07 #4
"UL-Tomten" <to****@gmail.comwrote in message
news:11*********************@l22g2000prc.googlegro ups.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 NotImplementedException("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_INI = @"%APPDATA%\Mozilla\Firefox
\profiles.ini";
private const string PATH_COOKIES_TXT = @"%APPDATA%\Mozilla\Firefox\
%PROFILE%\cookies.txt";
...
string pathAppData =
Environment.GetEnvironmentVariable("APPDATA");
string profilesIniPath = PATH_PROFILES_INI.Replace("%APPDATA%",
pathAppData);
string profileDir = null;
// Find default profile in profiles.ini
Dictionary<string, string>[] firefoxProfilesIni =
ParseIniFile(profilesIniPath);
foreach (Dictionary<string, stringiniGroup in
firefoxProfilesIni) {
if (iniGroup.ContainsKey("Default") && iniGroup["Default"] ==
"1")
profileDir = iniGroup["Path"];
}
_cookiePath = PATH_COOKIES_TXT.Replace("%PROFILE%",
profileDir).Replace("%APPDATA%", pathAppData);
...
const string INI_PATTERN = @"\s*\[([^\]]*)\]\r?\n([^\[]*)";
public static Dictionary<string, string>[] ParseIniFile(string
IniFilePath) {
List<Dictionary<string, string>dictList = new
List<Dictionary<string, string>>();
string iniContents = File.ReadAllText(IniFilePath);
MatchCollection mc = Regex.Matches(iniContents, INI_PATTERN,
RegexOptions.Singleline);
foreach (Match m in mc) {
Dictionary<string, stringdict = new Dictionary<string,
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(newlines,
StringSplitOptions.RemoveEmptyEntries)) {
if (keyvalue.Contains("=")) {
dict.Add(keyvalue.Split('=')[0].Trim(),
keyvalue.Split('=')[1].Trim());
}
}
dictList.Add(dict);
}
return dictList.ToArray();
}
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
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...
0
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 ...
6
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...
4
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:...
20
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...
7
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...
1
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...
1
by: xcelmind | last post by:
Hello Dev. Guru, I want to at this time introduce myself. I am Stanley Ojadovwa by name. I’m a freelance and a newbie in web application development. I’m currently using ASP as my application...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.