Pages

Saturday, August 27, 2011

VS 2010 C# Generic Handlers

When I create a new C# generic handler, tow files are created:

  • C# code page
  • Markup page

C# code page is where all C# source code goes, and the Markup page is XML declaration markup.

C# code page example:

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Web;
   5: using adminDataContext;
   6: using System.Web.Script.Serialization;
   7:  
   8: namespace FileManager.ckeditor
   9: {
  10:     public class linkPages : IHttpHandler
  11:     {
  12:         protected class zPages
  13:         {
  14:             public int id { get; set; }
  15:             public int? categoryId { get; set; }
  16:             public string page { get; set; }
  17:             public string err { get; set; }
  18:             public string category { get; set; }
  19:         }
  20:  
  21:         private zPages requestVals = new zPages();

Markup page example:



   1: <%@ WebHandler Language="C#" CodeBehind="linkPages.ashx.cs" Class="FileManager.ckeditor.linkPages" %>

The Markup page resembles a code behind page where it is a sub file of the Code page with the Solution Explorer’s tree view.


Gaining access to the Martup page: Within the Solution Explorer’s tree view, right click on the Code page and select View Markup from the flyout.


Why I am writing this, because this is the second time wondering why that when I change the namespace name within the Code page, the application couldn’t find the changed  namespace. Searching the web revealed nothing too help me. Now that I have figured it out, I am documenting it just in case.


When I change the namespace in the Code page, I must also change it in the Markup page. Easy!!!! But I didn’t realize that their was a Markup page till I right clicked on the Code page and selecting View Markup.


All along I knew it had to something very simple, however this is the second time since I had not documented previous.


This blog is for my notes. Much of the code presented is work in process.

No comments:

Post a Comment