Click here to Skip to main content
15,923,087 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: .NET Languages and Namespaces [modified] Pin
.NET- India 10-Dec-07 2:58
.NET- India 10-Dec-07 2:58 
GeneralRe: .NET Languages and Namespaces Pin
.NET- India 10-Dec-07 2:45
.NET- India 10-Dec-07 2:45 
QuestionDocumentatioon/Help of some build related files Pin
Mushtaque Nizamani7-Dec-07 0:36
Mushtaque Nizamani7-Dec-07 0:36 
GeneralRe: Documentatioon/Help of some build related files Pin
Paul Conrad19-Jan-08 12:20
professionalPaul Conrad19-Jan-08 12:20 
GeneralReturn data from unmanaged code Pin
CodeWolf)6-Dec-07 23:51
CodeWolf)6-Dec-07 23:51 
GeneralRe: Return data from unmanaged code Pin
Paul Conrad19-Jan-08 12:21
professionalPaul Conrad19-Jan-08 12:21 
GeneralTracking progress of writing data to xml [modified] Pin
Oshtri Deka6-Dec-07 13:58
professionalOshtri Deka6-Dec-07 13:58 
GeneralError(404) when using HttpWebRequest and WebDav Pin
David5555-Dec-07 19:32
David5555-Dec-07 19:32 
Hi,

I try to connect the exchange 2003 using httpwebrequest .net class.
I am trying to get a list of foders using webdav. I took the script from the msdn site:
http://msdn2.microsoft.com/en-us/library/aa494246.aspx

We use exchange 2003 .
The build of the project succeeded but an error occured on this row :
Response = (HttpWebResponse)Request.GetResponse();
The error mesage is - The remote server returned an error: (404) Not Found.
I thought that the problem is in this url -
string strRootURI = http://mailit.com/exchange/davide/;
but when I try it in the IE , I see my inbox.
How can I solve this problem ?

Thanks,
David

The code I use:
<br />
using System.Net;<br />
using System.IO;<br />
using System.Text;<br />
using System.Xml;<br />
<br />
namespace ExchangeSDK.Snippets.CSharp<br />
<br />
{<br />
<br />
class GettingListOfFoldersWebDAV<br />
<br />
{<br />
<br />
[STAThread]<br />
<br />
static void Main(string[] args)<br />
<br />
{<br />
<br />
// Variables.<br />
System.Net.HttpWebRequest Request;<br />
System.Net.WebResponse Response;<br />
System.Net.CredentialCache MyCredentialCache;<br />
<br />
string strRootURI = http://mailit/exchange/davide/inbox;<br />
string strUserName = "a0dave";<br />
string strPassword = "123456";<br />
string strDomain = "mois";<br />
string strQuery = "";<br />
byte[] bytes = null;<br />
System.IO.Stream RequestStream = null;<br />
System.IO.Stream ResponseStream = null;<br />
System.Xml.XmlTextReader XmlReader = null;<br />
<br />
try<br />
<br />
{<br />
<br />
// Build the SQL query.<br />
strQuery = "";<br />
strQuery += "SELECT \"DAV:href\" FROM scope('hierarchical traversal of \"";<br />
<br />
strQuery += strRootURI + "\"')";<br />
// Create a new CredentialCache object and fill it with the network<br />
// credentials required to access the server.<br />
MyCredentialCache = new System.Net.CredentialCache();<br />
MyCredentialCache.Add(new System.Uri(strRootURI),<br />
"NTLM",<br />
new System.Net.NetworkCredential(strUserName, strPassword, strDomain)<br />
<br />
);<br />
<br />
// Create the HttpWebRequest object.<br />
<br />
Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strRootURI);<br />
<br />
// Add the network credentials to the request.<br />
<br />
Request.Credentials = MyCredentialCache;<br />
<br />
// Specify the method.<br />
<br />
Request.Method = "SEARCH";<br />
<br />
// Encode the body using UTF-8.<br />
bytes = Encoding.UTF8.GetBytes((string)strQuery);<br />
// Set the content header length. This must be<br />
// done before writing data to the request stream.<br />
Request.ContentLength = bytes.Length;<br />
// Get a reference to the request stream.<br />
RequestStream = Request.GetRequestStream();<br />
// Write the SQL query to the request stream.<br />
RequestStream.Write(bytes, 0, bytes.Length);<br />
// Close the Stream object to release the connection<br />
// for further use.<br />
RequestStream.Close();<br />
// Set the content type header.<br />
Request.ContentType = "text/xml";<br />
<br />
// Send the SEARCH method request and get the<br />
// response from the server.<br />
Response = (HttpWebResponse)Request.GetResponse();<br />
// Get the XML response stream.<br />
ResponseStream = Response.GetResponseStream();<br />
// Create the XmlTextReader object from the XML<br />
// response stream.<br />
XmlReader = new XmlTextReader(ResponseStream);<br />
<br />
// Read through the XML response, node by node.<br />
while (XmlReader.Read())<br />
{<br />
// Look for the opening DAV:href node. The DAV: namespace is<br />
//typically assigned the a: prefix in the XML response body.<br />
if (XmlReader.Name == "a:href")<br />
{<br />
// Advance the reader to the text node.<br />
XmlReader.Read();<br />
// Display the value of the DAV:href text node.<br />
Console.WriteLine("Value: " + XmlReader.Value);<br />
Console.WriteLine("");<br />
//Advance the reader to the closing DAV:href node.<br />
XmlReader.Read();<br />
}<br />
}<br />
// Clean up.<br />
XmlReader.Close();<br />
ResponseStream.Close();<br />
Response.Close();<br />
}<br />
<br />
catch (Exception ex)<br />
{<br />
// Catch any exceptions. Any error codes from the SEARCH<br />
// method request on the server will be caught here, also.<br />
Console.WriteLine(ex.Message);<br />
Console.ReadLine();<br />
}<br />
}<br />
}<br />
}<br />

GeneralDeploying .Net Server-Based Sql Server Application in Workgroup Environment Pin
DotNetWWW4-Dec-07 17:42
DotNetWWW4-Dec-07 17:42 
GeneralRe: Deploying .Net Server-Based Sql Server Application in Workgroup Environment Pin
Colin Angus Mackay5-Dec-07 2:54
Colin Angus Mackay5-Dec-07 2:54 
GeneralRe: Deploying .Net Server-Based Sql Server Application in Workgroup Environment Pin
DotNetWWW9-Dec-07 3:49
DotNetWWW9-Dec-07 3:49 
GeneralRe: Deploying .Net Server-Based Sql Server Application in Workgroup Environment Pin
Colin Angus Mackay9-Dec-07 5:23
Colin Angus Mackay9-Dec-07 5:23 
GeneralRe: Deploying .Net Server-Based Sql Server Application in Workgroup Environment Pin
Luis Alonso Ramos11-Dec-07 15:06
Luis Alonso Ramos11-Dec-07 15:06 
GeneralA Proxy to route ports Pin
Yevgeny Efter4-Dec-07 2:23
Yevgeny Efter4-Dec-07 2:23 
GeneralRe: A Proxy to route ports Pin
Dave Kreskowiak4-Dec-07 10:36
mveDave Kreskowiak4-Dec-07 10:36 
GeneralIntellisense not Working Pin
Brady Kelly4-Dec-07 1:39
Brady Kelly4-Dec-07 1:39 
General.net 2.0 Winform application not executing after installation... [modified] Pin
pnslcs3-Dec-07 10:43
pnslcs3-Dec-07 10:43 
GeneralRe: .net 2.0 Winform application not executing after installation... Pin
martin_hughes4-Dec-07 10:43
martin_hughes4-Dec-07 10:43 
GeneralRe: .net 2.0 Winform application not executing after installation... Pin
pnslcs10-Dec-07 8:15
pnslcs10-Dec-07 8:15 
GeneralRe: .net 2.0 Winform application not executing after installation... Pin
martin_hughes10-Dec-07 8:27
martin_hughes10-Dec-07 8:27 
GeneralRe: .net 2.0 Winform application not executing after installation... Pin
pnslcs10-Dec-07 8:34
pnslcs10-Dec-07 8:34 
QuestionStrange WPF behaviour in VS 2008... [modified] Pin
martin_hughes1-Dec-07 5:16
martin_hughes1-Dec-07 5:16 
GeneralRe: Strange WPF behaviour in VS 2008... Pin
Thomas Stockwell14-Apr-08 8:07
professionalThomas Stockwell14-Apr-08 8:07 
QuestionVS2005 Load Test Pin
alimohammed30-Nov-07 4:45
alimohammed30-Nov-07 4:45 
AnswerRe: VS2005 Load Test Pin
Paul Conrad1-Dec-07 15:28
professionalPaul Conrad1-Dec-07 15:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.