|
I'm guessing that you're calling Response.Write from the code-behind of an ASP.NET page? In which case, the content of the page will still be output to the response after the text you've passed to the Response.Write method. You'll need to call Response.End after your last call to Response.Write to prevent this.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I followed your instructions and now it works correctly.... I think I need to study better the way a web application works ....
Thank you very much.
Leo
|
|
|
|
|
Hi,
I have a question: I am want to add text (many strings) into file by using the method TextWriter.Write(), will this method append text into a file or overwrite the content of file ?
Are there any other ways to append text into file ?
Thanks and regards,
|
|
|
|
|
A writer will write its content at the current file location, and move the current location to the end of the written content. In typical usage this means that it will append each time you call it.
|
|
|
|
|
Using a StreamWriter [^] is generally a better choice. When you open the underlying FileStream you can specify whether to append or not by the mode option[^].
|
|
|
|
|
The TextWriter don't care. The state of the underlying Stream is what matters -- it can be opened to append or overwrite.
|
|
|
|
|
Thanks all of you.
I used StreamWriter for this.
Kind regards,
|
|
|
|
|
Hi All,
I have created an asp.net c# website that is being used like a helpdesk, tickets are being logged and resolved etc.
I now want to add a pop up that should appear on the user that logged the tickets' pc when the IT personnel updates the ticket.
I am not sure how or if you can use notifyicon to do this?
|
|
|
|
|
You would need to install an application on their machine which talked to the ticket server. There's no way to do that simply through a web interface.
|
|
|
|
|
Thank you for the response!
How would the application know which tickets belong to which user? - I have a username linked to the ticket and a ticket number.
Sorry if I sound stupid!
I don't know much about c# applications, I have only worked with websites.
|
|
|
|
|
If the user name was linked to their Windows Identity, then you can use that. If, however, your site uses a custom login mechanism or something like OAuth, then the user is going to have to associate their identity with the notification application - this would typically require you to provide a settings page where they entered their user name and password details so that you could verify that they were a valid user.
To be honest, this opens a whole can of worms, including things such as verifying that web service requests haven't been intercepted and so on. A simpler method would just be to email them.
|
|
|
|
|
Thank you so much!
I would just use email, but my company wants the pop up. They want to move away from emails.
I think I found my solution!
|
|
|
|
|
NickyRamshaw wrote: I think I found my solution!
Only if the user has a Windows machine. What do you do if they only ever use an iPad? Or how about those few people using WinRT? Perhaps they only use Linux boxes.
|
|
|
|
|
how i can convert this code from java to c#
public static String Dcipher(String encryptedText1) {
try {
byte[] desKeyData = {(byte) 0x01, (byte) 0x02, (byte) 0x03,
(byte) 0x04, (byte) 0x05, (byte) 0x06,
(byte) 0x07, (byte) 0x08};
DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = null;
try {
key = keyFactory.generateSecret(desKeySpec);
} catch (InvalidKeySpecException ex1) {
}
byte[] initVector = new byte[] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01,
0x01,
0x02};
AlgorithmParameterSpec algParamSpec = new IvParameterSpec(
initVector);
Cipher m_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
m_decrypter.init(Cipher.DECRYPT_MODE, key, algParamSpec);
byte[] encryptedText = encryptedText1.getBytes();
byte[] decryptedText = m_decrypter.doFinal(encryptedText);
return (new String(decryptedText));
} catch (BadPaddingException ex) {
ex.printStackTrace();
} catch (IllegalBlockSizeException ex) {
ex.printStackTrace();
} catch (InvalidAlgorithmParameterException ex) {
ex.printStackTrace();
} catch (InvalidKeyException ex) {
ex.printStackTrace();
} catch (NoSuchPaddingException ex) {
ex.printStackTrace();
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
return "";
}
|
|
|
|
|
|
I don't have a conversion for some of the Java types you're using, but the following syntax should be correct:
public static string Dcipher(string encryptedText1)
{
try
{
sbyte[] desKeyData = {(sbyte) 0x01, (sbyte) 0x02, (sbyte) 0x03, (sbyte) 0x04, (sbyte) 0x05, (sbyte) 0x06, (sbyte) 0x07, (sbyte) 0x08};
DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = null;
try
{
key = keyFactory.generateSecret(desKeySpec);
}
catch (InvalidKeySpecException ex1)
{
}
sbyte[] initVector = new sbyte[] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01, 0x01, 0x02};
AlgorithmParameterSpec algParamSpec = new IvParameterSpec(initVector);
Cipher m_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
m_decrypter.init(Cipher.DECRYPT_MODE, key, algParamSpec);
sbyte[] encryptedText = encryptedText1.Bytes;
sbyte[] decryptedText = m_decrypter.doFinal(encryptedText);
return (new string(decryptedText));
}
catch (BadPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (IllegalBlockSizeException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidAlgorithmParameterException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidKeyException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchAlgorithmException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
return "";
}
Dave Doknjas
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
|
|
|
|
|
I am getting a timeout message when accessing a linq to sql object in a C# 2010 application. This error message is occuring when I am doing a select in the linq to sql object. thus can you tell me how I can increase the timeout on the linq to sql data set object? The following os the error message I am getting:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
2013-01-24 16:40:03.3082|ERROR|Sample|************* Stack Trace *******************
2013-01-24 16:40:03.3238|ERROR|Sample| at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
|
|
|
|
|
You may be causing the exception yourself, if it happens after a period of time or after a number of connection attempts. Try reading this[^] for a brief discussion on the topic.
If it's the first connection attempt your code makes to the database, you've got a problem with your connection string or the database engine isn't responding for some reason or ...
|
|
|
|
|
How is this question different than the one that you posted 3 days ago?
|
|
|
|
|
1. You already posted a similar question a while back. I suggested logging. Did you implement that? Logging a stack trace is not enough.
2. Try setting a break point in the catch that generates this message and check your variables. In LINQ you should be able to retreive the SQL that is sent to the database, find it and try to execute in SQL Server directly. If necessary, type it over in the SQL manager by hand.
3. A timeout is there for a reason, you should only increase the timeout if you're absolutely certain that procedure is lengthy. Honestly, based on your questions I don't think that is the case here. increasing the timeout could at best, be a workaround, not a solution.
|
|
|
|
|
hi dears...
i want the activity-selection algorithm in c#.
thanks for u...
|
|
|
|
|
There are many ways to select an activity. If you have a problem with some code you have written, feel free to post a question on it. Good luck.
|
|
|
|
|
sorry, my meaning was activity-selection algorithm that is greedy algorithm in C#. i have a project for university, i thanks so much if u help me.
best regards...
|
|
|
|
|
So you're trying to get me to pass your course. If you can't solve this, how do you expect to do this as a career?
|
|
|
|
|
I'm assuming you're talking about this[^]. Start there and write your own code. It's what you're going to school for or getting paid to write isn't it?? Either way, we're not writing your code for you.
|
|
|
|