"HTTP 403 Forbidden" error when downloading file on Pocket PC

G

Guest

Hello,

I have developed web service, which is called by my application for checking
updates. If update is found then path of the related cab file is returned to
application. In application, I am programmatically downloading files on
Pocket PC by following code.

This code works fine when I configure my web service locally (local IIS). I
am able to download cab file but in case of live address this code gives
“HTTP 403 forbidden†error.

When I try to open the same cab file from pocket pc’s IE then it can be
downloaded via IE on Pocket PC, but when I try to download it
programmatically it gives error.

'Used for creating Request.
Dim LOC_Req As HttpWebRequest
Dim LOC_Resp As HttpWebResponse

' Retrieve response stream
Dim LOC_RespStream As Stream
'Used Create local cab file
Dim LOC_Wrtr As FileStream
Dim LOC_BytesRead As Integer = 0
' Allocate byte buffer to hold stream contents
Dim LOC_InData(4095) As Byte
Try
'Creating request
LOC_Req = CType(WebRequest.Create(DownloadUrl), HttpWebRequest)
'Set http-request's method to "GET"
LOC_Req.Method = "GET"
'Get Response.
LOC_Resp = CType(LOC_Req.GetResponse(), HttpWebResponse)
'Check if available space on device is less than or equal to
size of cab file.
'Get Response's stream.
LOC_RespStream = LOC_Resp.GetResponseStream()
'Create a file.
LOC_Wrtr = New FileStream(LocalFile, FileMode.Create)
'loop through response stream reading each data block
'and writing to the local file
LOC_BytesRead = LOC_RespStream.Read(LOC_InData, 0, LOC_InData.Length)
While LOC_BytesRead > 0
LOC_Wrtr.Write(LOC_InData, 0, LOC_BytesRead)
LOC_BytesRead = LOC_RespStream.Read(LOC_InData, 0,
LOC_InData.Length)
End While
Catch Ex As Exception
'Set object of Exception. Calling application will have
'read only access to this object.
MsgBox(Ex.Message)
Finally
LOC_RespStream.Flush()
'Closing Response stream
LOC_RespStream.Close()
'Closing writer stream
LOC_Wrtr.Close()
End Try
End Sub 'DownloadFileBinary

Please guide me.
 
W

William LaMartin

I think what is need is something like this in the web.config file if you
want to use Get or Post

system.web>
<webServices>
<protocols>
<add name="HttpPost" />
<add name="HttpGet" />
</protocols>
</webServices>
</system.web>
 
A

Alex Feinman [MVP]

Can you check the IIS log to see the exact query the IIS is receving?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top