February 10th, 2009 — 5:33am
Handlerlar default olarak session değerlerini getirmiyorlar.
Erişmek istediğinizde null oluyor. Eğer null olmasın istiyorsanız IRequiresSessionState veya IReadOnlySessionState interfacelerini implemente etmeniz gerekiyor.
using System.Web;
using System.Web.SessionState;
public class MyHandler : IHttpHandler, IRequiresSessionState
{
public MyHandler()
{
}
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
//do work
context.Session["MyValue"] = "New Value";
}
#endregion
}
Comment » | Asp.Net
January 30th, 2009 — 3:32am
by using this static method we can shutdown our web application. Maybe it is not so useful, but we should know…
//Terminates the current application, it restarts next time it is requested.
System.Web.HttpRuntime.UnloadAppDomain();
msdn
Comment » | Asp.Net
January 26th, 2009 — 4:55am
When we need javascript actions from asp.net we need to use RegisterClientScriptBlock method.
it is a better practice to make a js actions class and put your common js methods in it.
this little method below alerts from any page when you call the JsAlert Method.
JsActions.JsAlert("Hi Serdar ;)");
public static class JsActions
{
public static void JsAlert(string alertText)
{
Page p = HttpContext.Current.Handler as Page;
p.ClientScript.RegisterClientScriptBlock(p.GetType(),
"myAlert",
string.Format("<script>alert('{0}');</script>", alertText));
}
}
dotnetslackers
Comment » | Asp.Net