473,398 Members | 2,113 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,398 software developers and data experts.

.htaccess and NetworkCredentials question

Hi,

I'm writing a C# app to retrieve a web page which is protected by a
..htaccess file. I've been trying various things for a while and
continue to get a network exception:

The remote server returned an error: (401) Unauthorized.

Can anyone tell me where I am going wrong? My current code effort is:

....
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(URL);

myReq.MaximumAutomaticRedirections = 4;
myReq.MaximumResponseHeadersLength = 4;

myReq.Credentials = new System.Net.NetworkCredential("myuser",
"letmein");

....

Many thanks in advance,

Matt.
Nov 16 '05 #1
3 2405
I'm writing a C# app to retrieve a web page which is protected by a
.htaccess file. I've been trying various things for a while and
continue to get a network exception:


The keyword of yout text is "protected by .htaccess". If a derective like
"Deny from all" exist in .htaccess in the folder from wich you want to get
the page, you'll get nothing but 401. Apache won't allow you to view any
page you have no viewing rights for.

Gaidar
Nov 16 '05 #2
Gaidar wrote:
I'm writing a C# app to retrieve a web page which is protected by a
.htaccess file. I've been trying various things for a while and
continue to get a network exception:

The keyword of yout text is "protected by .htaccess". If a derective like
"Deny from all" exist in .htaccess in the folder from wich you want to get
the page, you'll get nothing but 401. Apache won't allow you to view any
page you have no viewing rights for.

Gaidar


Its safe to say that he already knows that and he has the username and
password.
Nov 16 '05 #3
> Gaidar wrote:
The keyword of yout text is "protected by .htaccess". If a derective like
"Deny from all" exist in .htaccess in the folder from wich you want to get
the page, you'll get nothing but 401. Apache won't allow you to view any
page you have no viewing rights for.

Gaidar


I know the .htaccess works because I can use the username and password
to gain access through a browser.

I just need to get the code to do the same.
Nov 16 '05 #4

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

Similar topics

13
by: Bob Bedford | last post by:
I've protected a directory with an .htaccess file. I'd like some of the files in this directory to be accessible by a scheduler that runs an "URL". The problem is that the scheduler runs scripts...
3
by: frizzle | last post by:
Hi there, I've posted the following question elsewhere, but got no response, and there seems to be no special htaccess-group, so i took the liberty to post it here. Hope y'all dont mind. I...
0
by: Stoco | last post by:
I am trying to create a generic interface that will manage various ..htaccess protected directories. In the ideal world, the .htaccess would trigger a cgi script that would take login information...
3
by: Vardan Kushnir | last post by:
Please forgive me if my English is poor. Also please tell me if this is wrong place to ask this question and tell me better place. When searching web for information Re: .htaccess and...
0
by: Jack Hambabo | last post by:
Hi, I'm searching for a php script that can find out whether the current user (I know _SERVER will give me the name for non-cgi php) has the right to view a specific file. My dream is that I...
0
by: Russell | last post by:
I am using a NetworkCredential object with a web ReportViewer to access ReportingServices: ReportViewer1.ServerReport.ReportServerCredentials = new Cred(); The "Cred" object implements...
4
by: xiaawan | last post by:
Hi All I am not sure the right forum for this question regarding .htaccess but in the past I got too much help from this forum.Anyhow my probolem is as follows. I am using .htaccess to redirect...
4
by: adnanjunk | last post by:
Hi, Having a little issue with .htaccess not working on windows server. I have clean url's setup using the htaccess file, working fine on linux server. I have researched for a while and found...
6
by: mrozko | last post by:
Hi, I hope my message is not "out of topic".... I would like to make "clean URLs" on my website.... Is it possible to make something like this: orig. URL: /inde.php?mcat=1&subcat=2
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.