Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

401 unauthorized message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Blasting Cap - 06 Mar 2008 18:33 GMT
I've got a web service that had been functioning up until I moved it to
a new server a while back.

It basically is a screen scrape that grabs off html off a UPS or Fedex
web page.

All of a sudden, I'm getting a 401 Unauthorized message when I try to
run it.  So is another application that references this same web service.

When I moved IIS (2000 to server 2003), I copied & thought I had all the
websites set up exactly the same way.  However, this web service has not
functioned and has repeatedly given this same error.  The code that
actually gives the error is:

   Case "UPSC"
                            sURL =
"http://wwwapps.ups.com/etracking/tracking.cgi?tracknums_displayed=5&TypeOfInquir
yNumber=T&HTMLVersion=4.0&sort_by=status&InquiryNumber1
="
& sBol(i) &
"&InquiryNumber2=&InquiryNumber3=&InquiryNumber4=&InquiryNumber5=&track=Track"
                            MyPage.Text = MyPage.Text +
oReadHTMPage.readHtmlPage(sURL, "UPSC", sBol(i), sTemp(i)con

The context of the error message is:

System.Net.WebException was unhandled by user code
  Message="The request failed with HTTP status 401: Unauthorized."
  Source="System.Web.Services"
  StackTrace:
       at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
       at RemSQL.com.remlink.www.Tracker.UPS(String Nr)
       at RemSQL.RemSQL.readHtmlPage(String url, String sCarr, String
sPro, String sPro1)
       at test.POInquiry.BillofLading() in
C:\Inetpub\wwwroot\test\Sales\POInquiry.aspx.vb:line 1426
       at test.POInquiry.ShowTracking() in
C:\Inetpub\wwwroot\test\Sales\POInquiry.aspx.vb:line 1497
       at test.POInquiry.Tracking_Select(Object Sender, EventArgs E) in
C:\Inetpub\wwwroot\test\Sales\POInquiry.aspx.vb:line 1481
       at
System.Web.UI.WebControls.BaseDataList.OnSelectedIndexChanged(EventArgs e)
       at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object
source, EventArgs e)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source,
EventArgs args)
       at System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object
source, EventArgs e)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source,
EventArgs args)
       at
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       at
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument)
       at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The reference.vb file that gets called eventually is:


<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.myserver.com/trackingstatus/UPS",
RequestNamespace:="http://www.myserver.com/trackingstatus",
ResponseNamespace:="http://www.myserver.com/trackingstatus",
Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
 _
        Public Function UPS(ByVal Nr As String) As Object
            Dim results() As Object = Me.Invoke("UPS", New Object() {Nr})
            Return CType(results(0),Object)
        End Function

I've gone thru and changed the Anonymous access to enable it, both at
the folder level for the tracking status, as well as to temporarily
enabling anonymous access on the server (it needs to be NT Challenge
Response to access it).

How can I tell what entity is requesting authentication?

BC
nano2k - 07 Mar 2008 14:41 GMT
> I've got a web service that had been functioning up until I moved it to
> a new server a while back.
[quoted text clipped - 85 lines]
>
> BC

Some checks to do:
1. NTFS access rights on files for NETWORK SERVICES user.
2. Go to IIS Console (Control Panel/Administrative Tools). Select your
site, go to properties, then select ASP.NET tab and check if the site
is enabled with the correct version.
Blasting Cap - 10 Mar 2008 18:56 GMT
I've tried both suggestions:

> Some checks to do:
> 1. NTFS access rights on files for NETWORK SERVICES user.
> 2. Go to IIS Console (Control Panel/Administrative Tools). Select your
> site, go to properties, then select ASP.NET tab and check if the site
> is enabled with the correct version.

both with zero success.

The site is set to the correct version (although it stopped working when
it was brought up to version 2), but I converted all the code and it
tested fine when I tested it.  Now, I can't get it to work either in
test or production.

BC

>> I've got a web service that had been functioning up until I moved it to
>> a new server a while back.
[quoted text clipped - 91 lines]
> site, go to properties, then select ASP.NET tab and check if the site
> is enabled with the correct version.
Blasting Cap - 13 Mar 2008 18:03 GMT
Nano2k -

I finally got the problem fixed.

It was indirectly the issue you mentioned.  Everything was as it should
have been when the system was moved over.

However, it wasn't until I went into the main site, and added a virtual
directory for the tracking service, that it actually started working.

The post that I found that put things together was this:

Creating a Virtual Directory
August 19, 2003 22:58 by admin

I always wondered what the differences were between creating virtual
directory using the IIS and through Windows Explorer (Web Sharing).

I found out today after spending over an hour trying to figure out why I
was getting this error when calling my web service from a windows
client: WebException: The request failed with HTTP status 401: Unauthorized

The reason is that when you create a Virtual Directory through IIS the
default permission for the directory is Anonymous but when using Windows
Explorer the default permission is set to Integrated Window Authentication.

located here:
http://www.merill.net/category/ASPNET.aspx

The virtual directory was copied using Windows Explorer, and it wasn't
until I did the exact same thing via IIS, that the $#$(*&$# thing
started working.

I have no idea why one would make any difference than the other - by
creating it in IIS, it changed nothing on the properties of the virtual
directory that I can see.

Thanks for the help.

BC

>> I've got a web service that had been functioning up until I moved it to
>> a new server a while back.
[quoted text clipped - 91 lines]
> site, go to properties, then select ASP.NET tab and check if the site
> is enabled with the correct version.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.