Today in the background management system does not refresh the left menu, encountered two challenges: (CTE recursive query, ashx+session[])

Source: Internet
Author: User

Today in the background management system does not refresh the left menu, encountered two challenges:

1. How to query the menu items in the data table hierarchically by tree structure? I was told by someone in the group to use the CTE recursive query, I still do not understand.

2, to do the left navigation bar according to the user permissions of the non-flush load, to use Ajax, then the general processing program in ASHX to obtain the value of session["UserID", but ASHX is not used session, and then found an article, Point out: To use session and request in ashx, you need to introduce an interface.

Use session and QueryString in the Ashx file

There are three points to note:

1. The using System.Web.SessionState should be added to the namespace;

2. Interface name to join IRequiresSessionState or ireadonlysessionstate;

3. Both the session and the QueryString are acquired through HttpContext.

The specific code is as follows:

1234567891011121314151617181920212223242526 <%@ WebHandler Language="C#" Class="UploadHandler" %>using System;using System.IO;using System.Net;using System.Web;using System.Web.SessionState;public class UploadHandler : IHttpHandler, IRequiresSessionState{         public void ProcessRequest (HttpContext context) {        context.Response.ContentType = "text/plain";        context.Response.Charset = "utf-8";        string str1 = context.Session["aaa"].ToString();        string str2 = context.Request.QueryString["bbb"].ToString();    }     public bool IsReusable {        get {            return false;        }    }}

Today in the background management system does not refresh the left menu, encountered two challenges: (CTE recursive query, ashx+session[])

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.