|
|
Really sorry for bugging you. But the "unvalidated" is showing error.
it says it doesnt contain a definition for unvalidated.
|
|
|
|
|
<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
</configuration>
Use above section in config file.
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
Thanks.
It still showing tht problem. tried tweaking things up but aint working.
Will try more.
|
|
|
|
|
there are lots of discussion on similar error. you can try one of the solution and let me know, in case you have any issue.
best luck
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
I got that.
One more question.
Suppose i want to get the html of facebook.com. it'll give me that. but once i login,it will still give the old i.e the default html code. how to get the new changed code?
|
|
|
|
|
never tried with facebook or such a big sites but for security reason they may have restricted such request. but try with storing session information and crawl all the links on the page.
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
Thanks a lot.
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["action"] != null)
{
if (Session["chatHistory"] == null)
{
Session["chatHistory"] = new Hashtable(); ;
}
if (Session["openChatBoxes"] == null)
{
Session["openChatBoxes"] = new Hashtable();
}
if (Session["tsChatBoxes"] == null)
{
Session["tsChatBoxes"] = new Hashtable();
}
switch (Request.QueryString["action"].ToString())
{
case "chatheartbeat":
{
chatHeartbeat();
break;
}
case "sendchat":
{
sendChat();
break;
}
case "closechat":
{
closeChat();
break;
}
case "startchatsession":
{
startChatSession();
break;
}
}
}
Hashtable s = new Hashtable();
}
private void sendChat()
{
string from = Request.Form["from"];
Session["username"] = from; // Assign Session user name value to $from value
string to = Request.Form["to"]; // Assign POST FORM 'To' value to $to value}
string message = Request.Form["message"]; // Assign POST FORM 'message' value to $message value
if (Session["openChatBoxes"] != null)
((Hashtable)(Session["openChatBoxes"]))[to] = DateTime.Now.ToString("Y-m-d H:i:s");
string messagesan = sanitize(message);
if (Session["chatHistory"] != null)
{
if (((Hashtable)(Session["chatHistory"])).Contains(Request.Form["to"]))
{
((Hashtable)(Session["chatHistory"]))[to] = "";
//((Hashtable)(Session["chatHistory"]))[getIndexOf(((Hashtable)(Session["chatHistory"])), Request["to"])] = "";
}
}
if (Session["chatHistory"] != null)
((Hashtable)(Session["chatHistory"]))[to] += "\"s\":\"1\",\"f\":\"{" + to + "}\",\"m\":\"{" + messagesan + "}\"";
if (Session["tsChatBoxes"] != null)
((Hashtable)(Session["tsChatBoxes"]))[to] = null;
/* Add Insert Query here*/
SqlDataProvider sqd4 = new SqlDataProvider();
string ConnectionString4 = sqd4.ConnectionString;
SqlConnection cnn4 = new SqlConnection(ConnectionString4);
cnn4.Open();
string query4 = "insert into dnn_DNAiusMessage_1 (UserFrom,UserTo,MessageContent,SendTime,Received) Values('" + from + "','" + to + "','" + message
+ "','" + DateTime.Now + "','" + 0 + "')";
SqlCommand cmd4 = new SqlCommand(query4, cnn4);
SqlDataReader reader = cmd4.ExecuteReader();
Response.Write("1");
Response.End();
}
private string sanitize(string text)
{
//text = htmlspecialchars(text, ENT_QUOTES); // Convert the html special characters
text = text.Replace("\n\r", "\n");
text = text.Replace("\r\n", "\n");
text = text.Replace("\n", " ");
return text;
}
private void startChatSession()
{
string from = Request.Form["from"];
Session["username"] = from;
string items = "";
if (Session["openChatBoxes"] != null)
{ // Check the Session variable
System.Collections.Hashtable openChatBoxesArray = (Hashtable)(Session["openChatBoxes"]);
for (int i = 0; i < openChatBoxesArray.Count; i++)
{ // Loop the session array
items += chatBoxSession(i); // Append to Items variable
}
}
if (items != string.Empty)
{
items = items.Substring(0, items.Length - 1);
}
HttpContext.Current.Response.Write("{ ");
HttpContext.Current.Response.Write("\"username\": \"" + HttpContext.Current.User.Identity.Name + "\","); // Display the Username Which is set in the session
HttpContext.Current.Response.Write("\"items\": [");
HttpContext.Current.Response.Write(items);
HttpContext.Current.Response.Write("]");
HttpContext.Current.Response.Write("}");
Response.End();
}
private string chatBoxSession(int chatbox)
{
string items = "";
if (((Hashtable)(Session["chatHistory"]))[chatbox] != null)
{ // Check the Session variable
items = ((Hashtable)(Session["chatHistory"]))[chatbox].ToString();
}
return items;
}
private void closeChat()
{
int chatbox = 1; //value of chatbox
try
{
((Hashtable)(Session["openChatBoxes"]))[chatbox] = null;
}
catch
{
}
Response.Write("1");
}
private int getIndexOf(Hashtable SessionArray, string Value)
{
// try
// {
// return SessionArray.in((object)Value);
// }
// catch
// {
return 0;
//}
}
private void chatHeartbeat()
{
//string to = Request.QueryString["UserName"].ToString();
// Session["username1"] = to; // Assign Session user name value to $from value
/* Add the Code to get the chat from the databse here and assign the result to datatable dtChat */
string ConString = ConfigurationManager.AppSettings["SiteSqlServer"];
CHATDataContext ObjDataContext = new CHATDataContext(ConString);
// var messages = ObjDataContext.GetNotRecieved(User.Identity.Name);
var q = from a in ObjDataContext.dnn_DNAiusMessage_1
where a.UserFrom == User.Identity.Name && a.Received == Convert.ToInt32(1)
select a;
// System.Collections.Generic.GenericCollection<dnn_dnaiusmessage_1> messages = ObjDataContext.GetNotRecieved(User.Identity.Name);
// System.Collections.Generic.List<dnn_dnaiusmessage_1> messages = ObjDataContext.GetNotRecieved(User.Identity.Name);
List<dnn_dnaiusmessage_1> messages = q.AsEnumerable().ToList();
string items = "";
foreach (dnn_DNAiusMessage_1 message in q)
{
if (Session["openChatBoxes"] != null && Session["chatHistory"] != null)
{
if (!((Hashtable)(Session["openChatBoxes"])).Contains(message.UserFrom) && ((Hashtable)(Session["chatHistory"])).Contains(message.UserFrom))
{
items = ((Hashtable)(Session["chatHistory"]))[message.UserFrom].ToString();
}
}
message.MessageContent = sanitize(message.MessageContent);
// Response.Write(message.MessageContent);
//items = items + "{\"s\": \"0\",\"f\": \"" + message.UserFrom.ToString() + "\",\"m\": \"" + "ggg" + "\"}, ";
//items = items + "\"s\":\"0\",\"f\":\"{" + message.UserFrom.ToString() + "}\",\"m\":\"{" + "GOOOOP" + "}\"";
items = items + "{\"s\": \"0\",\"f\": \"" + message.UserFrom.ToString() + "\",\"m\": \"" + message.MessageContent + "\"}, ";
if (Session["chatHistory"] != null)
{
if (!((Hashtable)(Session["chatHistory"])).Contains(message.UserFrom))
{
((Hashtable)(Session["chatHistory"]))[message.UserFrom] = "";
}
}
if (Session["chatHistory"] != null)
((Hashtable)(Session["chatHistory"]))[message.UserFrom.ToString()] += "\"s\":\"0\",\"f\":\"{" + message.UserFrom.ToString() + "}\",\"m\":\"{" + message.MessageContent + "}\"";
if (Session["tsChatBoxes"] != null)
((Hashtable)(Session["tsChatBoxes"]))[message.UserFrom.ToString()] = null; // Unset means clear the session value
if (Session["openChatBoxes"] != null)
((Hashtable)(Session["openChatBoxes"]))[message.UserFrom.ToString()] = message.SendTime;
}
if (Session["openChatBoxes"] != null)
{
Hashtable openChatBoxesArray = (Hashtable)(Session["openChatBoxes"]);
for (int i = 0; i < openChatBoxesArray.Count; i++)
{
int chatbox = i;
if (openChatBoxesArray[i] != null)
{
DateTime time = (DateTime)(openChatBoxesArray[i]);
string timeval = "";
TimeSpan Now = (TimeSpan)(DateTime.Now - time);
timeval = time.ToString("g:iA M dS");
string message1 = "Sent at " + timeval;
if (Now.Minutes > 180)
{
// items = items + "{\"s\": \"0\",\"f\": \"" + message.UserFrom.ToString() + "\",\"m\": \"" + message.MessageContent + "\"}, ";
items += "\"s\":\"2\",\"f\":\"{" + chatbox.ToString() + "}\",\"m\":\"{" + message1 + "}\"";
if (((Hashtable)(Session["chatHistory"]))[chatbox] != null)
{
((Hashtable)(Session["chatHistory"]))[chatbox] = "";
}
((Hashtable)(Session["chatHistory"]))[chatbox] += "\"s\":\"2\",\"f\":\"{" + chatbox.ToString() + "}\",\"m\":\"{" + message1 + "}\"";
((Hashtable)(Session["tsChatBoxes"]))[chatbox] = "0";
}
}
}
}
ObjDataContext.UpdateRecieved(User.Identity.Name);
ObjDataContext.SubmitChanges();
if (items != string.Empty)
{
items = items.Substring(0, items.Length - 1);
}
HttpContext.Current.Response.Write("{ ");
Response.Write("\"items\":[" + items + "]");
HttpContext.Current.Response.Write(" }");
Response.End();
}
Chat Application Code is not Working .Please any
one help me. problem is i am not recieving the message
it will be stored into database.but i am not getting the message in browser. please help me
|
|
|
|
|
It's very difficult to read your code,
you can get the messages from database by pulling it with given interval. you can create timer and append new messages in the panel. you can add panel inside UpdatePanel. You will not see any postback if you will use UpdatePanel.
Best luck
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
REGULAR EXPRESSION FOR CAR ENGINE IN
TWO ALPHA 2 NUMBER 2 ALPHA 4 NUMBER
|
|
|
|
|
IF YOU WRITE IN ALL CAPS, ITS LIKE SHOUTING.
PEOPLE DO NOT TAKE KINDLY TO BEING SHOUTED AT IN REAL LIFE, THE INTERNET IS NO DIFFERENT!
|
|
|
|
|
Why are you yelling at me.
My children have learned very early on that yelling is not the way to get an answer from someone. It is only a way to make them angry.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
All you need is a price and I may buy it
|
|
|
|
|
REGULAR EXPREESION FOR CAR ENGINE NUMBER
IN THIS SERIAL
TWO ALPHA TWO NUMBER TWO ALPHA FOUR NUMBER
NEED EXPRESSION FOR THIS
|
|
|
|
|
Not exactly a difficult one, but Expresso[^] will help you.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
Given the following code in an .ASPX webforms application :
try
{
Response.Redirect("somePage.aspx");
}
catch (Exception ex)
{
}
finally
{
}
I'm wondering if the code in the Finally block (or any code that might be outside of the whole try/catch) would ever be hit.
Doesn't the Response.Redirect() immediately redirect making any code that follows useless? Or do I just not understand how this works?
|
|
|
|
|
Not trying to be a smart-ass, but why don't you just try it?
Place some dummy code in the finally block and see if it executes. (Use a break-point)
My hunch is that the finally code will execute. Also it may depend on which event the Response-Redirect is placed. (PageLoad, PageInit, ButtonClick, etc)
Post your results, so we all can learn.
|
|
|
|
|
I'm beyond mortified that I didn't think of that. Especially since after posting the question I ran the code to check something else, but putting a break point there just never occurred to me.
Ok, so thanks to David's suggestion I have an answer.
As it is written that code will throw an exception on the Response.Redirect with the following message:
Quote: {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} However, it still does the redirect after going through the finally block.
Changing the Response.Redirect to
Response.Redirect("SomePage.aspx", false);
will save it from throwing the exception, but will still run the code in the finally and any code after it and then will do the Redirect.
Live and learn.
modified 11-Dec-12 9:26am.
|
|
|
|
|
As you've already figured out, code in the finally block is guaranteed to execute no matter what (unless the runtime host decides otherwise or a system error forcefully terminates the process itself)
|
|
|
|
|
Finally block will always execute, no matter if you redirect your page or throwing some exception.
Finally block will not execution on only Some Exceptions[^]
When you pass 2nd optional Boolean parameter, it indicate whether you would like to complete page execution or just want to redirect page and leave current execution.
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|
|
You already have your answer but to explain Response.Redirect a little more: It is telling the Response object to redirect the user to the new page. What happens is the client gets that message and then requests somePage.aspx. So, it roundtrips but your C# thread will finish. It's essentially just adding a property to the Response object.
Server.Transfer will still finish your C# thread (finally will still run) but the client will not roundtrip. Execution will stay on the server and go to somePage.aspx and execute it and send the Response object back to the client.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Very well put. Thanks ryanb31.
|
|
|
|
|
when i m trying to update image in sql database i m getting error as"Cannot bulk load. The file "System.Byte[]" does not exist."
my code is as follows.pls help.
protected void Button1_Click(object sender, EventArgs e)
{
{
if (FileUpload1.HasFile)
{
byte[] productImage = FileUpload1.FileBytes;
string constr = "Server=AOD257; Database=Edusocial;User ID=sa; Password=password";
string query = "UPDATE Profile SET [Pic] = (SELECT Pic.* from Openrowset(Bulk '" + productImage + "', Single_Blob) MyImage) where Id =11651658";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@Pic", SqlDbType.Image).Value = productImage;
con.Open();
int result = com.ExecuteNonQuery();
con.Close();
if (result > 0)
{
Response.Redirect("Default.aspx");
}
}
else
{
lblmessage.Text = "Please Select Image File";
lblmessage.Visible = true;
}
}
}
|
|
|
|