Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

HTTPWebRequest.request.GetResponse fails: remote server re..

 
   Web Hosting and Web Master Forums (Home) -> IIS RSS
Next:  OWA connection error  
Author Message
Grant_Sutty

External


Since: Mar 20, 2007
Posts: 2



(Msg. 1) Posted: Tue Mar 20, 2007 11:14 am
Post subject: HTTPWebRequest.request.GetResponse fails: remote server returned error: (401) unauthorized.
Archived from groups: microsoft>public>inetserver>iis (more info?)

I have an asp.net web application which posts a request to another
asp.net web application. I am coding in C# using Visual studio 2003,
with .Net Framework 1.1 on a Wiondows 2003 server (running IIS 6.0.).
In order to have all code running as managed code, I changed existing
code which uses MSXML ServerXMLHTTPClass to post requests to code
using the .Net HTTPWebRequest class. When migrating the application to
the Test web server, IIS appears to prevent access (=no record of the
request in the Windows\System32\Logfiles\W3SVC1 files). I am using
impersonation in the web.config file of the client and 'server' web
applications. The Application needs to be configured in IIS to
'Windows Authentication' only. The impersonated account is a member of
IIS_WPG group an has NTFS permissions to the Applications physical
folder. Even if I open up security (allow everyone). There is no web
proxy issue. Both client and Server applications are at this point
both on the same Test server with the same specs as the development
machine (above).

THE ONLY WAY IT FUNCTIONS IS IF IIS FOR THE APPLICATION ON THE SERVER
HAS 'ENABLE ANONYMOUS' TICKED.

I see a lot of posts on the internet highlighting this problem without
any difinitive answer. Surely, Microsoft wishes the Managed classes to
be used. Why then does there appear to be such a hassle for coders to
use the class to achieve the same result as the MSXML classes?

The code below is what I am using to make the call. Tracing shows that
the call fails when the request is made (GetResponse()).

HttpWebRequest request=null;
Uri uri = new Uri(requestTargetAndQuery);
request = (HttpWebRequest) WebRequest.Create(uri);
request.Method = "GET";
request.Credentials = new NetworkCredential(this.m_User,
this.m_Password);
string result=string.Empty;
using (HttpWebResponse response = (HttpWebResponse)
request.GetResponse())
{
request response.",traceSwitch);
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader readStream = new StreamReader
(responseStream, Encoding.UTF8))
{ result = readStream.ReadToEnd();
}
}
}

Hopefully someone can point me in the right direction (or let me know
if the Framework class does not have the capability to achieve what I
am trying)

Thanks Grant_S

 >> Stay informed about: HTTPWebRequest.request.GetResponse fails: remote server re.. 
Back to top
Login to vote
Steve Schofield

External


Since: Nov 26, 2006
Posts: 221



(Msg. 2) Posted: Thu Mar 22, 2007 10:47 pm
Post subject: Re: HTTPWebRequest.request.GetResponse fails: remote server returned error: (401) unauthorized. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Grant,

Have you tried using BASIC Authentication and / or Windows Integrated
Authentication to see if this works?
--

Steve Schofield
Windows Server MVP - IIS
ASPInsider Member - MCP

http://www.orcsweb.com/
Managed Complex Hosting
#1 in Service and Support

"Grant_Sutty" <sutcliffe.grant.RemoveThis@gmail.com> wrote in message
news:1174414466.211293.254830@e1g2000hsg.googlegroups.com...
>I have an asp.net web application which posts a request to another
> asp.net web application. I am coding in C# using Visual studio 2003,
> with .Net Framework 1.1 on a Wiondows 2003 server (running IIS 6.0.).
> In order to have all code running as managed code, I changed existing
> code which uses MSXML ServerXMLHTTPClass to post requests to code
> using the .Net HTTPWebRequest class. When migrating the application to
> the Test web server, IIS appears to prevent access (=no record of the
> request in the Windows\System32\Logfiles\W3SVC1 files). I am using
> impersonation in the web.config file of the client and 'server' web
> applications. The Application needs to be configured in IIS to
> 'Windows Authentication' only. The impersonated account is a member of
> IIS_WPG group an has NTFS permissions to the Applications physical
> folder. Even if I open up security (allow everyone). There is no web
> proxy issue. Both client and Server applications are at this point
> both on the same Test server with the same specs as the development
> machine (above).
>
> THE ONLY WAY IT FUNCTIONS IS IF IIS FOR THE APPLICATION ON THE SERVER
> HAS 'ENABLE ANONYMOUS' TICKED.
>
> I see a lot of posts on the internet highlighting this problem without
> any difinitive answer. Surely, Microsoft wishes the Managed classes to
> be used. Why then does there appear to be such a hassle for coders to
> use the class to achieve the same result as the MSXML classes?
>
> The code below is what I am using to make the call. Tracing shows that
> the call fails when the request is made (GetResponse()).
>
> HttpWebRequest request=null;
> Uri uri = new Uri(requestTargetAndQuery);
> request = (HttpWebRequest) WebRequest.Create(uri);
> request.Method = "GET";
> request.Credentials = new NetworkCredential(this.m_User,
> this.m_Password);
> string result=string.Empty;
> using (HttpWebResponse response = (HttpWebResponse)
> request.GetResponse())
> {
> request response.",traceSwitch);
> using (Stream responseStream = response.GetResponseStream())
> {
> using (StreamReader readStream = new StreamReader
> (responseStream, Encoding.UTF8))
> { result = readStream.ReadToEnd();
> }
> }
> }
>
> Hopefully someone can point me in the right direction (or let me know
> if the Framework class does not have the capability to achieve what I
> am trying)
>
> Thanks Grant_S
>

 >> Stay informed about: HTTPWebRequest.request.GetResponse fails: remote server re.. 
Back to top
Login to vote
Grant_Sutty

External


Since: Mar 20, 2007
Posts: 2



(Msg. 3) Posted: Fri Mar 23, 2007 1:05 am
Post subject: Re: HTTPWebRequest.request.GetResponse fails: remote server returned error: (401) unauthorized. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mar 23, 2:47 am, "Steve Schofield" <s... RemoveThis @orcsweb.com> wrote:
> Hi Grant,
>
> Have you tried using BASIC Authentication and / or Windows Integrated
> Authentication to see if this works?
> --
>
> Steve Schofield
> WindowsServerMVP - IIS
> ASPInsider Member - MCP
>
> http://www.orcsweb.com/
> Managed Complex Hosting
> #1 in Service and Support
>
> "Grant_Sutty" <sutcliffe.gr... RemoveThis @gmail.com> wrote in message
>
> news:1174414466.211293.254830@e1g2000hsg.googlegroups.com...
>
>
>
> >I have an asp.net web application which posts a request to another
> > asp.net web application. I am coding in C# using Visual studio 2003,
> > with .Net Framework 1.1 on a Wiondows 2003server(running IIS 6.0.).
> > In order to have all code running as managed code, I changed existing
> > code which uses MSXML ServerXMLHTTPClass to post requests to code
> > using the .Net HTTPWebRequest class. When migrating the application to
> > the Test webserver, IIS appears to prevent access (=no record of the
> > request in the Windows\System32\Logfiles\W3SVC1 files). I am using
> > impersonation in the web.config file of the client and 'server' web
> > applications. The Application needs to be configured in IIS to
> > 'Windows Authentication' only. The impersonated account is a member of
> > IIS_WPG group an has NTFS permissions to the Applications physical
> > folder. Even if I open up security (allow everyone). There is no web
> > proxy issue. Both client andServerapplications are at this point
> > both on the same Testserverwith the same specs as the development
> > machine (above).
>
> > THE ONLY WAY IT FUNCTIONS IS IF IIS FOR THE APPLICATION ON THESERVER
> > HAS 'ENABLE ANONYMOUS' TICKED.
>
> > I see a lot of posts on the internet highlighting this problem without
> > any difinitive answer. Surely, Microsoft wishes the Managed classes to
> > be used. Why then does there appear to be such a hassle for coders to
> > use the class to achieve the same result as the MSXML classes?
>
> > The code below is what I am using to make the call. Tracing shows that
> > the callfailswhen the request is made (GetResponse()).
>
> > HttpWebRequest request=null;
> > Uri uri = new Uri(requestTargetAndQuery);
> > request = (HttpWebRequest) WebRequest.Create(uri);
> > request.Method = "GET";
> > request.Credentials = new NetworkCredential(this.m_User,
> > this.m_Password);
> > string result=string.Empty;
> > using (HttpWebResponse response = (HttpWebResponse)
> > request.GetResponse())
> > {
> > request response.",traceSwitch);
> > using (Stream responseStream = response.GetResponseStream())
> > {
> > using (StreamReader readStream = new StreamReader
> > (responseStream, Encoding.UTF8))
> > { result = readStream.ReadToEnd();
> > }
> > }
> > }
>
> > Hopefully someone can point me in the right direction (or let me know
> > if the Framework class does not have the capability to achieve what I
> > am trying)
>
> > Thanks Grant_S- Hide quoted text -
>
> - Show quoted text -

Hi Steve

Thanks for your input. I finally got there yesterday. I am now able to
use IIS Windows Integrated only, I have 'allow' and 'deny' tags set
in the application web.config file; I am using the <impersonating >
tag in the web.config file. The thing that I had incorrect was that I
needed to use the 'domain' property when setting the network
credentials.

Cheers

Grant
 >> Stay informed about: HTTPWebRequest.request.GetResponse fails: remote server re.. 
Back to top
Login to vote
Steve Schofield

External


Since: Nov 26, 2006
Posts: 221



(Msg. 4) Posted: Fri Mar 23, 2007 9:59 am
Post subject: Re: HTTPWebRequest.request.GetResponse fails: remote server returned error: (401) unauthorized. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

That is great information. Thanks for posting the resolution.

--

Thank you,

Steve Schofield
Windows Server MVP - IIS
ASPInsider Member - MCP

http://www.orcsweb.com/
Managed Complex Hosting
#1 in Service and Support

"Grant_Sutty" <sutcliffe.grant RemoveThis @gmail.com> wrote in message
news:1174637120.792413.10060@b75g2000hsg.googlegroups.com...
> On Mar 23, 2:47 am, "Steve Schofield" <s... RemoveThis @orcsweb.com> wrote:
>> Hi Grant,
>>
>> Have you tried using BASIC Authentication and / or Windows Integrated
>> Authentication to see if this works?
>> --
>>
>> Steve Schofield
>> WindowsServerMVP - IIS
>> ASPInsider Member - MCP
>>
>> http://www.orcsweb.com/
>> Managed Complex Hosting
>> #1 in Service and Support
>>
>> "Grant_Sutty" <sutcliffe.gr... RemoveThis @gmail.com> wrote in message
>>
>> news:1174414466.211293.254830@e1g2000hsg.googlegroups.com...
>>
>>
>>
>> >I have an asp.net web application which posts a request to another
>> > asp.net web application. I am coding in C# using Visual studio 2003,
>> > with .Net Framework 1.1 on a Wiondows 2003server(running IIS 6.0.).
>> > In order to have all code running as managed code, I changed existing
>> > code which uses MSXML ServerXMLHTTPClass to post requests to code
>> > using the .Net HTTPWebRequest class. When migrating the application to
>> > the Test webserver, IIS appears to prevent access (=no record of the
>> > request in the Windows\System32\Logfiles\W3SVC1 files). I am using
>> > impersonation in the web.config file of the client and 'server' web
>> > applications. The Application needs to be configured in IIS to
>> > 'Windows Authentication' only. The impersonated account is a member of
>> > IIS_WPG group an has NTFS permissions to the Applications physical
>> > folder. Even if I open up security (allow everyone). There is no web
>> > proxy issue. Both client andServerapplications are at this point
>> > both on the same Testserverwith the same specs as the development
>> > machine (above).
>>
>> > THE ONLY WAY IT FUNCTIONS IS IF IIS FOR THE APPLICATION ON THESERVER
>> > HAS 'ENABLE ANONYMOUS' TICKED.
>>
>> > I see a lot of posts on the internet highlighting this problem without
>> > any difinitive answer. Surely, Microsoft wishes the Managed classes to
>> > be used. Why then does there appear to be such a hassle for coders to
>> > use the class to achieve the same result as the MSXML classes?
>>
>> > The code below is what I am using to make the call. Tracing shows that
>> > the callfailswhen the request is made (GetResponse()).
>>
>> > HttpWebRequest request=null;
>> > Uri uri = new Uri(requestTargetAndQuery);
>> > request = (HttpWebRequest) WebRequest.Create(uri);
>> > request.Method = "GET";
>> > request.Credentials = new NetworkCredential(this.m_User,
>> > this.m_Password);
>> > string result=string.Empty;
>> > using (HttpWebResponse response = (HttpWebResponse)
>> > request.GetResponse())
>> > {
>> > request response.",traceSwitch);
>> > using (Stream responseStream = response.GetResponseStream())
>> > {
>> > using (StreamReader readStream = new StreamReader
>> > (responseStream, Encoding.UTF8))
>> > { result = readStream.ReadToEnd();
>> > }
>> > }
>> > }
>>
>> > Hopefully someone can point me in the right direction (or let me know
>> > if the Framework class does not have the capability to achieve what I
>> > am trying)
>>
>> > Thanks Grant_S- Hide quoted text -
>>
>> - Show quoted text -
>
> Hi Steve
>
> Thanks for your input. I finally got there yesterday. I am now able to
> use IIS Windows Integrated only, I have 'allow' and 'deny' tags set
> in the application web.config file; I am using the <impersonating >
> tag in the web.config file. The thing that I had incorrect was that I
> needed to use the 'domain' property when setting the network
> credentials.
>
> Cheers
>
> Grant
>
 >> Stay informed about: HTTPWebRequest.request.GetResponse fails: remote server re.. 
Back to top
Login to vote
Anthony Jones

External


Since: Jan 28, 2006
Posts: 113



(Msg. 5) Posted: Thu Dec 06, 2007 8:32 am
Post subject: Re: remote server returned error: (401) unauthorized [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

<dishant buch> wrote in message
news:200712612255dishant.buch@eclipsys.com...
> can you please describe your solution in detail and if possible can you
please paste your code
>

Make sure the user accessing the resource is authorised to read it.

If you want a detailed answer ask a detailed question.

--
Anthony Jones - MVP ASP/ASP.NET
 >> Stay informed about: HTTPWebRequest.request.GetResponse fails: remote server re.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
writing to remote server fails after going to non anonymou.. - win 2k iis server. My web site has an asp page that needs to write a file to a remote server. I have created a comain user for the anonymous user. This works fine unless a page that is non- anonymous first and then goes to the page that is supposed ...

IIS 6 HTTP GET Request Fails if headers have LF instead of.. - I have the following problem: I submit GET requests to an IIS 6 server. I have specific headers that are separated by linefeeds (char 10, \r). Under IIS 5, these requests are processed fine. But under IIS6, it is ignoring these headers. To get things to...

IIS 6.0 on Win 2003 server fails to start - I'm having a problem with new installations of IIS 6.0 on 2003 server. The IIS Admin service fails to start with "Error 2: The system cannot find the file specified" The only message in event viewer is ID 7023, with the same message. I've re...

login to IIS fails when behind ISA server ? - login to IIS fails when behind ISA server ? Hi, From customer 2000 server behind ISA server im trying to connect to my IIS machine running sharepoint. When selecting the link im normally prompted for USER + PASS but from the site i get: HTTP 401.2 -....

XP 64 Server.CreateObject fails 32-bit dll - I spent several hours tonight trying to figure out why I was getting an ActiveX create object error. Initially I assumed it must be a security error, granting everyone/iusr/iwam/anon permissions to the dlls, disabled integrated and set anon account to..
   Web Hosting and Web Master Forums (Home) -> IIS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]