TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
RM M
NA
1
776
handler doesn't work in cs file but works in ashx file
Dec 9 2015 4:45 PM
I am trying to run http handler. I have a enclosed code which works when I put it in ashx file directly but when I separate them and put it in cs file then it doesn't work and I am not sure why.
<%@ WebHandler Language="C#" Class="TheCityofCalgary.GSA.SharePoint.GSAClick" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Configuration;
using System.Net;
using System.Runtime.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Configuration;
namespace TheCityofCalgary.GSA.SharePoint
{
/// <summary>
/// a generic http handler to redirect the ClickLog to GSALoaction that is not accessible from the public
/// </summary>
public class GSAClick : IHttpHandler
{
/// <summary>
/// You will need to configure this handler in the web.config file of your
/// web and register it with IIS before being able to use it. For more information
/// see the following link: http://go.microsoft.com/?linkid=8101007
/// </summary>
#region IHttpHandler Members
private const string GSA_LOCATION_KEY = "GSALocation";
public static StreamWriter LogSW = null;
public bool IsReusable
{
// Return false in case your Managed Handler cannot be reused for another request.
// Usually this would be false in case you have some state information preserved per request.
get { return true; }
}
/// <summary>
/// Process incoming request and redirect to GSALocation
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
try
{
WebRequest _webRequest = WebRequest.Create(gsaLocation);
_webRequest.BeginGetResponse(new AsyncCallback(RespCallback), null);
}
catch (Exception ex)
{
Console.WriteLine("Exception GSAClick:");
Console.WriteLine("------------------------------");
Console.WriteLine(ex.Message);
Console.WriteLine("Stack trace:");
Console.WriteLine(ex.StackTrace);
if(!string.IsNullOrEmpty(ex.StackTrace))
Log("Statck Trace: "+ex.StackTrace, true, "info");
}
}
#endregion
#region Private
/// <summary>
/// Required for making a async call to GSALocation but not required for response
/// </summary>
/// <param name="ar"></param>
private static void RespCallback(IAsyncResult ar)
{
//do nothing
}
#endregion
}
}
And When I separate the code and leave enclsoed code in ashx file then it does not work:
<%@ WebHandler Language="C#" Class="TheCityofCalgary.GSA.SharePoint.GSAClick, TheCityofCalgary.GSA.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9cc8cc252281ce26" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Also, my handler does not run each time I run my query. It runs only when I go to the ashx file and save it and then run the query, it runs the handler. Again I am not sure why is that.
Any suggestion will be greatly appreciated.
Thanks in advance!!
Reply
Answers (
0
)
wcf
how to bind data to dropdown list more the 1000 items.