如何从HTML访问此Handler?

时间:2016-05-11 15:37:05

标签: c# html handler

我想从HTML表单访问此Handler

public class Eventos : 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

        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; }
        }

        public void ProcessRequest(HttpContext context)
        {
            //write your handler implementation here.
;

            string Tipo = context.Request.QueryString["Tipo"];

            switch (Tipo)
            {
                /*Pagina Index Portada Perfil -------------------------------------------------------------------------------------- */
                case "IndexSelectPerfil":
                    {
                        RegistroEvento(context);
                    }
                    break;
            }
        }

这就是我想在HTML表单上调用它的方式

<form class="form-header" action="IX_Registros.Handlers.Eventos" role="form" method="POST" id="#">

但是我无法访问它,并看到各种页面说要为处理程序创建一个ashx文件,但我不知道在哪里创建或使用它 我使用Visual Studio 2015社区并在Code On Time框架的帮助下创建它

1 个答案:

答案 0 :(得分:1)

我使用本指南http://codepedia.info/generic-handler-ashx-file-post-send-json-data-parameters-in-asp-net-c-jquery/访问处理程序并将JSON发布到我的HTML页面。