티스토리 뷰

카테고리 없음

사용자 정의 HtmlHelper

James Wetzel 2014. 5. 27. 11:16
728x90
반응형



클래스


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;


namespace Music.Web.Home.HtmlHelperExtension

{

    public static class BasicInfoExtension

    {

        /// <summary>

        /// ospID를 얻는다.

        /// </summary>

        /// <param name="helper"></param>

        /// <returns></returns>

        public static string ospID(this HtmlHelper helper)

        {

            return System.Web.Configuration.WebConfigurationManager.AppSettings["ospID"].ToString();

        }


        /// <summary>

        /// 사용자 아이디를 얻는다.

        /// </summary>

        /// <param name="helper"></param>

        /// <param name="request"></param>

        /// <returns></returns>

        public static string userID(this HtmlHelper helper, ViewContext viewContext)

        {

            string userID = viewContext.HttpContext.Request.Cookies["totorosa"] == null ? 

                            string.Empty : viewContext.HttpContext.Request.Cookies["totorosa"].Values["id"];


            if (!string.IsNullOrEmpty(userID))

            {

                userID = TOTO_LIB.Security.RijndaelAES.DecryptString(HttpUtility.UrlDecode(userID), System.Web.Configuration.WebConfigurationManager.AppSettings["RijndaelAESKey"]);

            }            


            return userID;

        }

    }

}



web.config

      <namespaces>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="Music.Web.Home.HtmlHelperExtension"/>
      </namespaces>



728x90
반응형