I have created a http handler fro my Jquery ajax call. which is working fine the jquery call is mentioned below
$.ajax({
url: \"Services/name.ashx\",
I found another way of doing this. If you want to access it from the same project it's is very easy.
Steps to use it in code behind
ProcessRequest.Suppose I have created a handler as follows
public class HandlerName : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//some code
}
public bool IsReusable
{
get
{
return false;
}
}
}
So you can use it as follows
HandlerName obj=new HandlerName();
obj.ProcessRequest(HttpContext);
Note that you can get the current context and you need to pass it in the process request. More about HttpContext [1 2]
You can also overload the ProcessRequest method in case if you need to do this.
public class HandlerName : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// some code
}
public void ProcessRequest(HttpContext context, string someString)
{
// do your coding here
}
public bool IsReusable
{
get
{
return false;
}
}
}
If you don't want to override the method the you can pass the values as follow
You can add the value in the HttpContext.Current.Items
HttpContext.Current.Items["ModuleInfo"] = "Custom Module Info"
and get it as follow in the ProcessRequest Method
public class HandlerName : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string contextData = (string)(HttpContext.Current.Items["ModuleInfo"]);
}
public bool IsReusable
{
get
{
return false;
}
}
}