Virtual Directory Hi,
How can I create a virtual directory in ASP.Net 2005
Is it necessary to create a virtual directory to have e web.config file for each of my folders in project (I create a web.config file but it sends me error for creating security)
bye Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

How to select unique values from a IList randomly? Please read my post and the code I sent before answering and giving new ideas. I want IList because Arrays, Collections and Lists implement it + it has built in support of this[ int index ] which if you look at my code, suits the best where I use object key = pool[rand.Next(pool_size)];
Second, I don't have any problems with shuffling or randomizing a list. I want to do exactly this:
I have an array, let's say :
int[ ] pool = new int[ ] { 1, 2, 2, 3, 4, 4, 5, 6, 6 }
and I want to get 2 int arrays each with 3 unique/distinct items such as ret1 = { 6, 2, 5} and ret2 = { 4, 1, 6 } BUT NEVER
invalidRet1 = { 2, 2, 4 } or invalidRet2 = { 6 , 6, 3 }. If the count parameter i use in my code is more than the unique items in my pool which are {1, 2, 3, 4, 5, 6} in a case of count = 10 then my function should return a result with a maximum of 6 items and they are of course {1, 2, 3, 4, 5, 6}. I use max_tries to prevent infinite loop of randomly selecting unique item which can occur if the pool size is very small or there are too many duplicate items in the pool. (pool = {1, 2, 2, 2, 2, 2, 3} and count = 3 where in my code rand.Next(pool_size) may return the index of item 2 {1, 2, 3, 4 or 5} for ever. Dictionary < object , object > I use in my code stores these randomly selected unique items. I hope it is more clear now. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

ThreadPool issue and doubts I have a windows serice in .NET 1.1 which call a service after every 10 sec. i am using following code :
// Set Timer interval.
this .DataManagementServiceTimer = new System.Threading.Timer( new TimerCallback( this .DataManagementServiceTimer_Elapsed), null , System.Threading.Timeout.Infinite,TimerInterval);
I have already installed the hot fix for this prob on windows 2003 provided by microsoft. but sometime timers stops firing and service status remains active so we could not know that service has stopped.
Is there any way to find that timers has stopped firing while its status remains active in my window servive code
Please let me know
Thanks Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

How to convert the .msi file to EXE How to convert the .msi file to EXE
I have IE7 admin kit .msi file. I want to convert as EXE file.
Otherwise send me the link for IE7 admin kit EXE.
please help....
Thanks,
Dharani. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

process kill, close, closemainwindow Standard output is often a buffered stream; which means the act of the application exiting flushes the buffer. If you kill the process, it doesn't exit normally so that buffer is not flushed.
Maybe if you provide reproducible sample code that causes the process stall when reading output we can offer some guidance on that issue. You should never need to kill a process. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Problem with SOAP Header in WSE 3.0 Using my development platform, I built a web services client, and I have successfully connected with the web service. My development platform consists of Windows XP and Visual Studio 2005. I used the WSE 3.0 configuration tool to build the policy file. The web service uses anonymousForCertificateSecuirty and has issued me the X509 certificate.
I then moved the web services client to my production server which is on web hosting account, and installed the X509 Certification. It seems that everything has been installed properly; however, when I execute the web client on the web server, I get the following error message: " Security requirements are not satisfied because the security header is not present in the incoming message ".
I enabled a diagnostic trace on both the development and production server and compared the first output soap header of both. I found that they were identical except for the following elements in the first soap header:
Soap Header segment that is correct (from development machine) :
< xenc:EncryptedKey Id = " SecurityToken-2e... " xmlns:xenc = " http://www.w3.org/2001/04/xmlenc# " >
< xenc:EncryptionMethod Algorithm = " http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p " >
< ds: DigestMethod xmlns: ds = " http://www.w3.org/2000/09/xmldsig # " Algorithm = " http://www.w3.org/2000/09/xmldsig#sha1 " />
</ xenc:EncryptionMethod >
< KeyInfo xmlns = " http://www.w3.org/2000/09/xmldsig# " >
Soap Header segment that is incorrect (from production machine) : < xenc:EncryptedKey Id = " SecurityToken-07... " xmlns:xenc = " http://www.w3.org/2001/04/xmlenc# " >
< xenc:EncryptionMethod Algorithm = " http://www.w3.org/2001/04/xmlenc#rsa-1_5 " />
< KeyInfo xmlns = " http://www.w3.org/2000/09/xmldsig# " >
As you you can see, the second soap header segment has created a different xenc:EncryptionMethod element containing the Algorithm = " http://www.w3.org/2001/04/xmlenc#rsa-1_5 " . The correct one should be Algorithm = " http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p " , and it should include the child element,
< ds: DigestMethod xmlns: ds = " http://www.w3.org/2000/09/xmldsig # " Algorithm = " http://www.w3.org/2000/09/xmldsig#sha1 " /> , but it does not.
Can you please assist me in trying to solve this problem Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Start/stop windows services on remote machine outside of current logon? Ok, thanks for the clarification. I think I finally understand what you're trying to do here and I apologize for being so dense.
If Machine B is not on the same domain as machine A, then the built-in Windows token management functionality (e.g. LogonUser + impersonation) will not work for you. Windows security is quite powerful, but it does rely on a centralize identity store (the domain controller) to work. If you don't have that DC in place, then Machine B's set of valid username/password combinations is only visible to Machine B. That means that Machine A cannot impersonate machine B.
You could invent a small custom authentication prototocol where you include a valid set of credentials (e.g. a username/password) along with the message you send to machine B. Machine B could use those credentials to call LogonUser() to get a locally valid token, and then impersonate that token for the duration of the operation.
However, I am really hesitant to suggest doing that unless you're quite sure of what you're doing. Any solution that involves sending username/passwords around (especially Administrator username/password combination) opens up your application to a bunch of potential attack vectors. You would need to protect these messages on the wire using some sort of encryption (HTTPS, probably) to make sure people can't sniff passwords off the network while these messages are in transit. You would probably want to have some form of machine identity validation on the remote endpoint (e.g. certificates) to prevent spoofing (sending the credentials to an evil machine masquerading as the machine you're trying to connect to).
If you go down that route, you should probably check out our guidance on .NET Remoting Security: http://msdn2.microsoft.com/en-us/library/aa302391.aspx#secnetch11_authentication
Alternatively, you could take a look at building your app on top of WCF instead of Remoting. The WCF net.tcp binding offers equivalent transport characteristics to Remoting, and the WCF security infrastructure offers first-class support for doing custom username/password authentication that doesn't require a domain controller. Here's a great article by one of our MVP's about how WCF security works: http://www.code-magazine.com/article.aspx quickid=0611051&page=1
If you decide to go down the WCF route, the WCF forum is here ( http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=118&SiteID=1 )
-steve Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Is this possible... Since the CLR is the Common Language Runtime, is it possible for an individual to create a proof-of-concept Runtime Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Console.Writeline formatting Hi I have a doubt in string formatting in Console.writeline.Why would i get a different output for following statements, i am not exactly formatting string in the sense , i am not using placeholders like {0} Console.WriteLine("{{", "x"); -> outputs { Console.WriteLine("{{"); -> ouputs {{ Can anyone please give an explanation for the same Thanks And Regards Anu Viswan www.AnuViswan.blogspot.com | www.mstechexperts.org Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Need help with C# and xpath Hi I Have a file that is an xml file but it does contain html code. The xml code inside is mathml code. Mathml is for making math equations. So you could have something like this: <math xmlns='http://www.w3.org/1998/Math/MathML'> <mrow> </mrow> . . . </math> Of course since you can have more then one equation you could have multiple statements of theses. I am not trying to load up this file and filter out all these mathml code in it and stick is into its own file. So if my xml document has 6 of these mathml equations 6 files will be created. I am kinda stuck on how to take this all out and then stick it into its own files. I have been able to read in the the whole xml document but I can't figure out how to seperate the code into their own files.
Code Block
/* This checks to see if the user has clicked on the ok button to open the file */ if (ofdOpenDocument.ShowDialog() != DialogResult.Cancel) { /* Makes a XmlDataDcoument called doc */ XmlDataDocument doc = new XmlDataDocument(); /* loads the users xml document they choose */ doc.Load(ofdOpenDocument.OpenFile()); /* finds all mathml root notes */ XmlNodeList nodes = doc.SelectNodes("//*[local-name()='math']"); /* tries to count how many equations there is */ int equations = nodes.Count; /* tries to display it in a label */ lblTest.Text = equations.ToString(); /* this takes the total number of mathml tag roots it finds and makes a new link label for * each node it finds. It then gives it a unquie name and adds it to the split container panel */ for (int i = 1; i <= nodes.Count; i++) { /*makes a dynamic label that will later be used to point to one of the newly created xml files * that contain a mathml equation */ LinkLabel makeLinkLabel = new LinkLabel(); makeLinkLabel.Text = " Equation " + i; /* this adds the label to a flowlay out panel */ this.flpEquationDisplay.Controls.Add(makeLinkLabel); } } } Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

How can i change the serial port configuration settings? Hi! This is my first post, so excuse me if i make some errors . I am experimenting with the SerialPort object, and i see that you can change its settings quite easily (ex. BaudRate, parity, etc), whenever my application is loaded, it performs ok. But in the Device Administrator, if i check the propierties of the COM port, they don¡¯t change along with the settings of my application. Is there any way to change it, that is, at the level of the Device Manager Thanks you very much for your responses! Antonio Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Read with encoding depending on culture Hello guys,
I have got a text file encoded in iso-8859-1. I want to read it with streamreader and an encoding depends on current culture. So if current culture is "tr-TR" it shall read it with "iso-8859-9" because this is the encoding to display the right characters in this language. Is there a culture - encoding relation in .Net
Thx,
fuddy Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Client Certificate SSL URI Problem I'm having a problem with a web service that I'm calling over SSL on a non-standard port using a client certificate that the web service checks for client identity. I configure my URI for my web service call to be in the format:
https://11.22.33.44:63251/ServiceName.asmx
If I make a call with my web proxy in this format I get back the expected null object from my web service call meaning that my client identity cannot be verified. As soon as I add the certificate to the web request the call blows up inside of the web service call.
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Invalid URI: The format of the URI could not be determined. 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) ...
Now I've not change the URL between calls, only added the certificate to the client collection. This works fine in our development environment running on port 443 without the port in the URI. Any suggestions would be appreciated. I don't know where else to look.
Thanks,
Steven Behnke Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Difference between ADO Execute and (Delete, Update, Addnew) This forum topic is for ADO. I am working in Pro*C to ADO equivalent conversion.
In Pro*C method, update, delete and insert sql statements are availabe. The same code should be used for both ORACLE and SQL Server database.
There are 2 approaches to convert these statements:
1. Connection.Execute "sql statement for update, delete or insert"
2. Open the Recordset with use of select statement for update, delete or insert. Change the feild values and call the Recordset.Update method for update query, Recordset.Delete method for delete query or Recordset.Addnew & Recordset.Update for insert query.
Which is the correct approach in ADO for the above 3 types of SQL statements Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Allocating large array -> out of memory Nope, not besides the possible workaround mentioned above. Hopefully they will make it easier to do in a later version of the CLR framework without jumping through additional hoops. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

File Mapping in .NET? I have to make a utility library for file mapping.
Any suggestion how to do it in .NET
Thanks a lot,
Dmitry Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

retrieving last entry yeap even if multiple users are connected scope_identity will return the current session last inserted id. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Extra item at end of file Hi , i'm using a stylesheet to transform and XML file into a text file. I'm looping through items and repeating each under each other in a text file ,at the end of each item i place an end flag of "_" , the problem is i only want it to appear after each item , but not the last item , so i need a way of either not 'printing' it out , or removing it from the end ...any ideas ... My stylesheet looks somehting like this: <xsl tylesheet version="1.0"> <xsl:for-each select="NewDataSet/Table"> <xsl:text>:Item1:</xsl:text> <xsl:text>XXX</xsl:text> <xsl:value-of select="ITEM_ID"/> <xsl:text>YYY</xsl:text> <xsl:value-of select="$newline"/> etc etc <xsl:text>-</xsl:text> <xsl:value-of select="$newline"/> </xsl:for-each> </xsl:template> </xsl tylesheet> So for each row , say i have 5 records i'll have a '_ ' flag at the end Sample output file : :Item1:XXX5555YYY _ :Item1:XXX1234YYY _ :Item1:XXX9999YYY _ :Item1:XXX7777YYY _ :Item1:XXX3333YYY _ My problem is , i want the "_" to appear after each record , bar the last record and hence the end of my text file . Since i'm in a foreach , it will repeat each time , even for my last reocrd, any ideas how i can remove it from the end , or prevent it appearing for the last record I'd like it to look like this : :Item1:XXX5555YYY _ :Item1:XXX1234YYY _ :Item1:XXX9999YYY _ :Item1:XXX7777YYY _ :Item1:XXX3333YYY Thanks for your help in advance , Regards , Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Microsoft.Jet.OLEDB.4.0 provider Is Microsoft.Jet.OLEDB.4.0 provider support transactions
Thanks in advance.
if the answer is yes i would be glad to have a reference for a good example for using begintransaction,commit, and rollback.
Thanks Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Remoting through SSL and Keep-Alives Hello,
My remoted objects are hosted in IIS. I am using HTTP and binary serializer for single-call activation. Due to scalability considerations, I prefer to have the Keep-Alives option turned off.
Now my task is to enable SSL on this channel. When Keep-Alives are turned off, a new connection is established between the client and the server for every remote call. Will this force the SSL handshake happen for every call as well In other words, must the Keep-Alives be enabled when SSL is in use
Thanks,
Val Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

How Should I Use one Dataset in all my project Forms? 1- How should i use one dataset in all of my project forms (only c#)
2- How should i use a variable or component from 1 form in another one (It was so easy to do this in Vb6 ) Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Need some help with forms and connections I have made a form with a datagridview of empinfo and I have put four buttons on it, HealthInfo, TrainingInfo, etc. and I want to be able to highlght an employee name in the gridview and open another window with the requested info in textboxs or listboxes, for example I want them to display the Health information table of the database.
What kind of code do I need I am using Visual Studio.
if someone could show me how to do one I could figure out the rest. The book Ive got does not show how to do this. Is this not a common application Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Data Access application Block With ODP.NET Hi All,
In my application I want to use the Data Access Application Block(DAAB) with the ODP.NET(Oracle Data provider for .NET i.e Oracle.DataAccess.Client). I have installed ODP.NET in my system I tested it by writing the sample application with out DAAB by using ODP.NET the application working fine.
In the Web.Config file I specified like this:
< connectionStrings >
< add name = " DbConnection " connectionString = " Data Source=xxx; User Id=sysdba; Password=xxx " providerName = " Oracle.DataAccess.Client; " />
</ connectionStrings >
And in the CS File I wrote the code like this :
Database db = DatabaseFactory .CreateDatabase( "DBConnection" );
DbCommand cmd = db.GetSqlStringCommand( "Select empno,ename from emp" );
DataSet ds = new DataSet ();
ds = db.ExecuteDataSet(cmd);
GridView1.DataSource = ds;
GridView1.DataBind();
When I run the application it is giving the following error:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Can any one help me how to solve this error.
Thanks in advance. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Problem writing to a file (C#) sw_ftp's declaration: private static StreamWriter sw_ftp; ie it is a class-level private variable. Re: your previous post, i redid the file creation section as follows: bool newFile; if (serviceStarted) { if (File.Exists(curPath + "\\FtpLog.txt")) newFile = true; else newFile = false; sw_ftp = new StreamWriter(curPath + "\\FtpLog.txt", true, Encoding.ASCII); if (!newFile) sw_ftp.WriteLine("\r\n"); } the writelinemakes no difference to the garbling of the text, i tried with and without, however allowing the streamwriter to create/open the file still garbles the last line of the file. Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

modify search path for assemblies I also struggle with this "design flaw" recently. .NET AppDomain is very much like Java ClassLoader namespace, and I have created many different versions of Java ClassLoader to customize the loading behavior. When I attempt to perform the same tasks in .NET, I found myself stranded with the current .NET design. All it needs to do is to provide a "CLASSPATH" equivalent property, or provide an extensible I/F where a developer can develop his own dll loading behavior. I truly hope MS .NET developer seriously consider adding back to the future releases Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

Please solve my Printing Problem Hi Tapan,
We are changing the issue type to ¡°Comment¡± because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to ¡°Question¡± by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Thank you! Tag: .NET Framework Networking and Communication WebClient.OpenWrite() .NET Development

shakalama

hi,

i'm learning network programming i use my localhost to do this, i got exception "(401) unauthorized ", is this a problem in my code or IIS , i had changed the access permission for this folder "ecommerce" to read and write but i still get this exceptin. is there any suggestion to avoid this

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

shakalama

hi,

ok let me rephrase my question i'm learning C# and i found this part in a book that i read now

"

There is also an

OpenWrite() method in the WebClient class. This method returns a writeable stream for you to send data to a URI. You can also specify the method used to send the data to the host; the default method is POST. The following code snippet assumes a writeable directory named ecommerce on the local machine. The code will create a file in the directory with the name newfile.txt and the contents

¡°Hello World¡±.

"

so the question is how to make a writeable direcotry in my local machine

i will also edit this thread subject from webclient.open write to "how to make a writeable direcotry in my local machine to test by it"

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

Jorg Jooss - MSFT

To answer your first question¡ªlike any process, IIS executes in the context of a Windows user account, and is limited to whatever this account is priviliged to do. A PUT request without authentification is executed as the anonymous user (IUSR_<machinename>).* In order to PUT a file in a directory served by IIS, IUSR_<machinename> requires NTFS write permissions on the physical directory.

But I've just realized that this seems to be the case by default. So once you've enabled PUT requests as mentioned before, the code should work right away (it works for me at least ).

* This assumes you didn't change the default configuration for anonymous users.

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

shakalama

hi, Jorg

sounds you miss understood me you talk about things as if i know how to do this, all my experience with IIS is that Asp pages need to setup IIS from control panel nothing more than that, and now i know new thing is how to tick "write" in directory tab

so if you don't mind tell me how to do what you are saying (NTFS wirting permission) or at least give me a direction where to find the solution

also i would like to ask about a good material to learn network programing

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

Jorg Jooss - MSFT

In Windows Explorer, right click the file or directory for which you want to change permissions, and select "Properties" and open the "Security" tab. Here you can assign detailed permissions like read, write, execute etc to any group or user.

If you don't see a Security tab, you first have to open Windows Explorer, select Tools->Folder Options¡­ On the "View" tab, make sure the option "Use simple file sharing (Recommded)" is not selected (that's one of the dumbest recommendations you'll ever find).

There are a few books on .NET network programming out there. I suggest you go to your favorite online book store, search for ".net network programming", and see what other people liked. Mind also the "network" in network programming¡ªif you have little or no idea of TCP/IP networking, you might want to start with a primer on networking before you start programming.

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

I scrutinized Web Developer debug messages & fields but these yielded no clues. The system log file did report an Authentication error.

I had unchecked the Tools=>Folder Options=>View->Use simple file sharing(Recommended) option.

But I still kept getting 401/403 errors

It was your advice to check the security tab on the folder that immediately showed the problem: IUSR_servername had no permissions checked and was therefore read-only. I set write permission & "hey-presto" WebClient.OpenWrite() worked !

Thank you.

One question though...The folder is a virtual web set up using IIS, so why doesn't IIS set the folder properties according to the security settings within IIS

Re: .NET Framework Networking and Communication WebClient.OpenWrite()

Jorg Jooss - MSFT

Peter ¡ª

such a feature cannot work in all cases. If you use Windows Authentication with impersonation, there's no way of infering the desired NTFS permissions from the IIS process identity, because that identity is not being used when performing the actual I/O operation.