/// <summary>Init(実装必須)</summary>
    /// <remarks>
    /// ・BeginRequest               :要求処理の開始前に発生
    /// ・AuthenticateRequest        :呼び出し元を認証
    /// ・AuthorizeRequest           :アクセスチェックを実行
    /// ・ResolveRequestCache        :キャッシュから応答を取得
    /// ・AcquireRequestState        :セッション状態をロード
    /// ・PreRequestHandlerExecute   :要求をハンドラオブジェクトに送信する直前に発生
    /// ・PostRequestHandlerExecute  :要求をハンドラオブジェクトに送信した直後に発生
    /// ・ReleaseRequestState        :セッション状態を保存
    /// ・UpdateRequestCache         :応答キャッシュを更新
    /// ・EndRequest                 :処理の終了後に発生
    /// ・PreSendRequestHeaders      :バッファ内の応答ヘッダーを送信する前に発生
    /// ・PreSendRequestContent      :バッファ内の応答本体を送信する前に発生
    /// </remarks>
    public void Init(HttpApplication application)
    {
        // ASP.NETイベント ハンドラを設定

        application.BeginRequest += (new EventHandler(this.Filter));

        //application.AuthenticateRequest += (new EventHandler(this.Filter));

        //application.AuthorizeRequest += (new EventHandler(this.Filter));

        //application.ResolveRequestCache += (new EventHandler(this.Filter));

        //application.AcquireRequestState += (new EventHandler(this.Filter));

        //application.PreRequestHandlerExecute += (new EventHandler(this.Filter));

        //application.PostRequestHandlerExecute += (new EventHandler(this.Filter));

        //application.ReleaseRequestState += (new EventHandler(this.Filter));

        //application.UpdateRequestCache += (new EventHandler(this.Filter));

        //application.EndRequest += (new EventHandler(this.Filter));

        //application.PreSendRequestHeaders += (new EventHandler(this.Filter));

        //application.PreSendRequestContent += (new EventHandler(this.Filter));
    }
 internal static void ExecuteStartPage(HttpApplication application)
 {
     ExecuteStartPage(application,
                      vpath => MonitorFile(vpath),
                      VirtualPathFactoryManager.Instance,
                      WebPageHttpHandler.GetRegisteredExtensions());
 }
		public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
		{
			string connectionTypeName;
			string providerAssemblyName;
			string cncString;

			this.config = config;

			GetConnectionData (out providerAssemblyName, out connectionTypeName, out cncString);
			if (cncType == null) {
				Assembly dbAssembly = Assembly.Load (providerAssemblyName);
				cncType = dbAssembly.GetType (connectionTypeName, true);
				if (!typeof (IDbConnection).IsAssignableFrom (cncType))
					throw new ApplicationException ("The type '" + cncType +
							"' does not implement IDB Connection.\n" +
							"Check 'DbConnectionType' in server.exe.config.");
			}

			cnc = (IDbConnection) Activator.CreateInstance (cncType);
			cnc.ConnectionString = cncString;
			try {
				cnc.Open ();
			} catch (Exception exc) {
				cnc = null;
				throw exc;
			}
		}
		/* stolen from the 1.0 S.W.Config ModulesConfiguration.cs */
		internal HttpModuleCollection LoadModules (HttpApplication app)
		{
			HttpModuleCollection coll = new HttpModuleCollection ();
			Type type;
			
			foreach (HttpModuleAction item in Modules){
				type = HttpApplication.LoadType (item.Type);
				
				if (type == null) {
					/* XXX should we throw here? */
					continue;
				}
				IHttpModule module = (IHttpModule) Activator.CreateInstance (type,
											     BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
											     null, null, null);
				module.Init (app);
				coll.AddModule (item.Name, module);
			}

			/* XXX the 1.x config stuff does this
			 * indirectly..  I'm not sure we want to do it
			 * here, but this keeps things working in much
			 * the same fashion in 2.0-land. */
			{
				IHttpModule module = new DefaultAuthenticationModule ();
				module.Init (app);
				coll.AddModule ("DefaultAuthentication", module);
			}

			return coll;
		}
示例#5
0
    public void Init(HttpApplication context)
    {
        context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);

        SessionStateModule sessionMod = (SessionStateModule)context.Modules["Session"];
        sessionMod.Start += new EventHandler(context_AuthenticateRequest);
    }
示例#6
0
 /// <summary>
 /// Initializes a module and prepares it to handle requests.
 /// </summary>
 /// <param name="context">An <see cref="T:System.Web.HttpApplication"></see> that provides access to the methods, 
 /// properties, and events common to all application objects within an ASP.NET application</param>
 public void Init(HttpApplication context)
 {
     context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute);
     SessionStateModule session = (SessionStateModule)context.Modules["Session"];
     session.End += new EventHandler(session_End);
     session.Start += new EventHandler(session_Start);
 }
示例#7
0
        private void InitializeRubyApplicationHooks(HttpApplication context)
        {
            if (_mvcApplication.IsNull()) return;

            context.Error += (sender, args) => _mvcApplication.Error(sender, args);
            context.AcquireRequestState += (sender, args) => _mvcApplication.AcquireRequestState(sender, args);
            context.AuthenticateRequest += (sender, args) => _mvcApplication.AuthenticateRequest(sender, args);
            context.AuthorizeRequest += (sender, args) => _mvcApplication.AuthorizeRequest(sender, args);
            context.BeginRequest += (sender, args) => _mvcApplication.BeginRequest(sender, args);
            context.Disposed += (sender, args) => _mvcApplication.Disposed(sender, args);
            context.EndRequest += (sender, args) => _mvcApplication.EndRequest(sender, args);
            context.LogRequest += (sender, args) => _mvcApplication.LogRequest(sender, args);
            context.PostAcquireRequestState += (sender, args) => _mvcApplication.PostAcquireRequestState(sender, args);
            context.MapRequestHandler += (sender, args) => _mvcApplication.MapRequestHandler(sender, args);
            context.PostAuthenticateRequest += (sender, args) => _mvcApplication.PostAuthenticateRequest(sender, args);
            context.PostAuthorizeRequest += (sender, args) => _mvcApplication.PostAuthorizeRequest(sender, args);
            context.PostLogRequest += (sender, args) => _mvcApplication.PostLogRequest(sender, args);
            context.PostMapRequestHandler += (sender, args) => _mvcApplication.PostMapRequestHandler(sender, args);
            context.PostReleaseRequestState += (sender, args) => _mvcApplication.PostReleaseRequestState(sender, args);
            context.PostRequestHandlerExecute += (sender, args) => _mvcApplication.PostRequestHandlerExecute(sender, args);
            context.PostResolveRequestCache += (sender, args) => _mvcApplication.PostResolveRequestCache(sender, args);
            context.PostUpdateRequestCache += (sender, args) => _mvcApplication.PostUpdateRequestCache(sender, args);
            context.PreRequestHandlerExecute += (sender, args) => _mvcApplication.PreRequestHandlerExecute(sender, args);
            context.PreSendRequestContent += (sender, args) => _mvcApplication.PreSendRequestContent(sender, args);
            context.PreSendRequestHeaders += (sender, args) => _mvcApplication.PreSendRequestHeaders(sender, args);
            context.ReleaseRequestState += (sender, args) => _mvcApplication.ReleaseRequestState(sender, args);
            context.ResolveRequestCache += (sender, args) => _mvcApplication.ResolveRequestCache(sender, args);
            context.UpdateRequestCache += (sender, args) => _mvcApplication.UpdateRequestCache(sender, args);
        }
 internal static void InitApplication(HttpApplication application)
 {
     // We need to run StartApplication first, so that any exception thrown during execution of the StartPage gets
     // recorded on StartPage.Exception
     StartApplication(application);
     InitializeApplication(application);
 }
 public void Init(HttpApplication context)
 {
     context.BeginRequest +=
     (new EventHandler(this.Application_BeginRequest));
     context.EndRequest +=
     (new EventHandler(this.Application_EndRequest));
 }
示例#10
0
    /// <summary>
    /// Compresses the response stream if the browser allows it.
    /// </summary>
    private static MemoryStream CompressResponse(Stream responseStream, HttpApplication app, string key)
    {
        MemoryStream dataStream = new MemoryStream();
        StreamCopy(responseStream, dataStream);
        responseStream.Dispose();

        byte[] buffer = dataStream.ToArray();
        dataStream.Dispose();

        MemoryStream ms = new MemoryStream();
        Stream compress = null;

        if (IsEncodingAccepted(DEFLATE))
        {
          compress = new DeflateStream(ms, CompressionMode.Compress);
          app.Application.Add(key + "enc", DEFLATE);
        }
        else if (IsEncodingAccepted(GZIP))
        {
          compress = new GZipStream(ms, CompressionMode.Compress);
          app.Application.Add(key + "enc", DEFLATE);
        }

        compress.Write(buffer, 0, buffer.Length);
        compress.Dispose();
        return ms;
    }
示例#11
0
文件: AsyncUtil.cs 项目: nobled/mono
        public static void WaitForAsyncResultCompletion(IAsyncResult asyncResult, HttpApplication app) {
            // based on HttpServerUtility.ExecuteInternal()

            if (!asyncResult.IsCompleted) {
                // suspend app lock while waiting, else might deadlock
                bool needToRelock = false;

                try {
                    // .NET 2.0+ will not allow a ThreadAbortException to be thrown while a
                    // thread is inside a finally block, so this pattern ensures that the
                    // value of 'needToRelock' is correct.
                    try { }
                    finally {
                        Monitor.Exit(app);
                        needToRelock = true;
                    }

                    WaitHandle waitHandle = asyncResult.AsyncWaitHandle;

                    if (waitHandle != null) {
                        waitHandle.WaitOne();
                    }
                    else {
                        while (!asyncResult.IsCompleted) {
                            Thread.Sleep(1);
                        }
                    }
                }
                finally {
                    if (needToRelock) {
                        Monitor.Enter(app);
                    }
                }
            }
        }
 public void Init(HttpApplication application)
 {
     application.BeginRequest +=
         (new EventHandler(this.Application_BeginRequest));
     application.EndRequest +=
         (new EventHandler(this.Application_EndRequest));
 }
        internal static void ExecuteStartPageInternal(HttpApplication application, Action<string> monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable<string> supportedExtensions)
        {
            ApplicationStartPage startPage = null;

            foreach (var extension in supportedExtensions)
            {
                var vpath = StartPageVirtualPath + extension;

                // We need to monitor regardless of existence because the user could add/remove the
                // file at any time.
                monitorFile(vpath);
                if (!virtualPathFactory.Exists(vpath))
                {
                    continue;
                }

                if (startPage == null)
                {
                    startPage = virtualPathFactory.CreateInstance<ApplicationStartPage>(vpath);
                    startPage.Application = application;
                    startPage.VirtualPathFactory = virtualPathFactory;
                    startPage.ExecuteInternal();
                }
            }
        }
示例#14
0
        private bool InitializeRubyApplication(HttpApplication context)
        {
            if (_mvcApplication.IsNotNull()) return false;

            _mvcApplication = _rubyEngine.ExecuteFile<MvcApplication>("~/mvc_application.rb",  false);
            if(_mvcApplication.IsNotNull()) _mvcApplication.Start(context, EventArgs.Empty);
            return true;
        }
		public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
		{
			this.config = config;
			RemotingConfiguration.Configure (null);
			string cons, proto, server, port;
			GetConData (config.StateConnectionString, out proto, out server, out port);
			cons = String.Format ("{0}://{1}:{2}/StateServer", proto, server, port);
			state_server = (RemoteStateServer) Activator.GetObject (typeof (RemoteStateServer), cons);
		}
示例#16
0
    /// <summary>
    /// Initializes a module and prepares it to handle requests.
    /// </summary>
    /// <param name="context">An <see cref="T:System.Web.HttpApplication"></see> 
    /// that provides access to the methods, properties, and events common to 
    /// all application objects within an ASP.NET application.
    /// </param>
    void IHttpModule.Init(HttpApplication context)
    {
        // For page compression
        context.PreRequestHandlerExecute += new EventHandler(context_PostReleaseRequestState);

        // For WebResource.axd compression
        context.BeginRequest += new EventHandler(context_BeginRequest);
        context.EndRequest += new EventHandler(context_EndRequest);
    }
示例#17
0
        /// <summary>
        /// initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        ///  An <see cref="T:System.Web.HttpApplication" /> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application 
        /// </param>
        public void Init(HttpApplication context)
        {
            context.EnsureArgumentNotNull("context");

            if (!InitializeRubyEngine(context)) return;
            if (!InitializeRubyApplication(context)) return;
            InitializeRubyApplicationHooks(context);

            _application = context;
        }
示例#18
0
		void ClearCookie (HttpApplication app, string cookieName)
		{
			HttpCookie clearCookie = new HttpCookie (_config.CookieName, "");

			clearCookie.Path = _config.CookiePath;
			clearCookie.Expires = DateTime.MinValue;
			clearCookie.Domain = _config.Domain;
			clearCookie.Secure = _config.CookieRequireSSL;
			app.Response.SetCookie (clearCookie);
		}
 public void Init(HttpApplication context)
 {
     if (!started)
     {
         lock (locker)
         {
             Start();
             started = true;
         }
     }
 }
示例#20
0
    private void PostRequestHandlerExecute(HttpApplication app)
    {
        string contentType = app.Response.ContentType;
        string method = app.Request.HttpMethod;
        int status = app.Response.StatusCode;
        IHttpHandler handler = app.Context.CurrentHandler;

        if (contentType == "text/html" && method == "GET" && status == 200 && handler != null)
        {
            app.Response.Filter = new WhitespaceFilter(app.Response.Filter, app.Request.ContentEncoding);
        }
    }
 /// <summary>
 /// Constructor which sets up the default logic to register Areas, Global Filters and standard MVC routes
 /// </summary>
 /// <param name="httpApplication"></param>
 /// <param name="containerBuilder"></param>
 /// <param name="mvcResolverFactory"></param>
 public UmbracoWebApplication(
     HttpApplication httpApplication,
     AbstractContainerBuilder containerBuilder,
     Func<IDependencyResolver, global::System.Web.Mvc.IDependencyResolver> mvcResolverFactory)
 {
     _mvcResolverFactory = mvcResolverFactory;
     _registerAreas = RegisterAllDefaultMvcAreas;
     _registerFilters = () => RegisterDefaultGlobalFilters(GlobalFilters.Filters);
     _registerDefaultRoutes = () => RegisterDefaultRoutes(RouteTable.Routes);
     _httpApplication = httpApplication;
     _containerBuilder = containerBuilder;
 }
        public ExcelExportFilter(Stream filterStream, HttpApplication application)
        {
            if (filterStream == null)
                throw new ArgumentNullException("filterStream");

            if (application == null)
                throw new ArgumentNullException("application");

            this.filterStream = filterStream;
            this.Application = application;
            this.temporaryStream = new MemoryStream();
        }
        public void Init(HttpApplication application)
        {
            if (application.Context.Items[_hasBeenRegisteredKey] != null)
            {
                // registration for this module has already run for this HttpApplication instance
                return;
            }

            application.Context.Items[_hasBeenRegisteredKey] = true;

            InitApplication(application);
        }
示例#24
0
    /// <summary>
    /// Adds a compressed byte array into the application items.
    /// <remarks>
    /// This is done for performance reasons so it doesn't have to
    /// create an HTTP request every time it serves the WebResource.axd.
    /// </remarks>
    /// </summary>
    private static void AddCompressedBytesToCache(HttpApplication app, string key)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(app.Context.Request.Url.OriginalString + "&c=1");
        using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
        {
          Stream responseStream = response.GetResponseStream();

          using (MemoryStream ms = CompressResponse(responseStream, app, key))
          {
        app.Application.Add(key, ms.ToArray());
          }
        }
    }
    // In the Init function, register for HttpApplication
    // events by adding your handlers.
    public void Init(HttpApplication application)
    {
        if (UserInfo.Debug())
        {
            application.BeginRequest +=
                (new EventHandler(this.Application_BeginRequest));
            application.EndRequest +=
                (new EventHandler(this.Application_EndRequest));
        }
        application.AuthenticateRequest += new EventHandler(this.AuthenticateRequest);

        //application.PostAcquireRequestState += new EventHandler(Application_PostAcquireRequestState);
        //application.PostMapRequestHandler += new EventHandler(Application_PostMapRequestHandler);
    }
示例#26
0
 private static bool RequestMayNeedIterationWithPersistence(HttpApplication application)
 {
     if (application == null)
     {
         return false;
     }
     HttpContext context = application.Context;
     if (context == null)
     {
         return false;
     }
     string extension = Path.GetExtension(context.Request.PhysicalPath);
     return ((extension != null) && (Array.IndexOf<string>(NoPersistenceFileExtensions, extension.ToLower()) < 0));
 }
 internal static void ExecuteStartPage(HttpApplication application, Action<string> monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable<string> supportedExtensions)
 {
     try
     {
         ExecuteStartPageInternal(application, monitorFile, virtualPathFactory, supportedExtensions);
     }
     catch (Exception e)
     {
         // Throw it as a HttpException so as to
         // display the original stack trace information.
         Exception = e;
         throw new HttpException(null, e);
     }
 }
        protected virtual void Init(HttpApplication application) {

            //////////////////////////////////////////////////////////////////
            // Check if this module has been already addded
            if (application.Context.Items[_contextKey] != null) {
                return; // already added to the pipeline
            }
            application.Context.Items[_contextKey] = _contextKey;

            // Ideally we would use the MapRequestHandler event.  However, MapRequestHandler is not available
            // in II6 or IIS7 ISAPI Mode.  Instead, we use PostResolveRequestCache, which is the event immediately
            // before MapRequestHandler.  This allows use to use one common codepath for all versions of IIS.
            application.PostResolveRequestCache += OnApplicationPostResolveRequestCache;
        }
        internal static void InitializeApplication(HttpApplication application, EventHandler onApplicationPostResolveRequestCache, EventHandler initialize)
        {
            if (initialize != null)
            {
                initialize(application, EventArgs.Empty);
            }
            application.PostResolveRequestCache += onApplicationPostResolveRequestCache;
            if (ApplicationStartPage.Exception != null || BeginRequest != null)
            {
                application.BeginRequest += OnBeginRequest;
            }

            application.EndRequest += OnEndRequest;
        }
示例#30
0
 /// <summary>
 /// Initializes the module and prepares it to handle requests.
 /// </summary>
 protected override void OnInit(HttpApplication application)
 {
     application.AssertNotNull("application");
     application.Error += new EventHandler(OnError);
     ErrorSignal.Get(application).Raised += new ErrorSignalEventHandler(OnErrorSignaled);
 }
 public void Init(HttpApplication context)
 {
     context.BeginRequest += Context_BeginRequest;
     context.EndRequest   += Context_EndRequest;
 }
示例#32
0
 public void Init(HttpApplication context)
 {
     context.EndRequest += new EventHandler(this.context_EndRequest);
 }
 /// <summary>
 /// Initialization method for the <see cref="IHttpModule"/>.
 /// </summary>
 /// <param name="application">
 /// An instance of the <see cref="HttpApplication"/>.
 /// </param>
 public void Init(HttpApplication application)
 {
     application.EndRequest += Application_EndRequest;
 }
示例#34
0
 private bool IsUploadRequest(HttpApplication application)
 {
     return(application.Request.ContentType.ToLower().StartsWith("multipart/form-data"));
 }
示例#35
0
 public void Init(HttpApplication context)
 {
     context.AuthorizeRequest += new EventHandler(context_AuthorizeRequest);
 }
示例#36
0
        void app_PreRequestHandlerExecute(object sender, EventArgs e)
		{
			HttpApplication app = (HttpApplication)sender;
			app.Context.Items[s_ItemKey] = DateTime.Now;
		}
示例#37
0
 public void SetApplication(HttpApplication value)
 {
     this.InternalApplicationOverride = value;
 }
 /// <summary>Initializes any data/resources on application start.</summary>
 /// <param name="context">The application context that instantiated and will be running this module.</param>
 public virtual void OnStart(HttpApplication context)
 {
     // put your application start code here
 }
示例#39
0
 public void Init(HttpApplication context)
 {
     context.BeginRequest += new EventHandler(context_BeginRequest);
     context.EndRequest   += new EventHandler(context_EndRequest);
 }
示例#40
0
 public void Init(HttpApplication context)
 {
     // attach to an event
     // Example: application.BeginRequest += new EventHandler(this.BeginRequest);
 }
示例#41
0
 protected override void OnInit(HttpApplication httpApplication)
 {
     httpApplication.PreRequestHandlerExecute += OnPreRequestHandlerExecute;
 }
        public void Init(HttpApplication context)
        {
            context.BeginRequest += InitDnn;

            context.PreSendRequestHeaders += this.OnPreSendRequestHeaders;
        }
示例#43
0
        public void context_AuthorizeRequest(object sender, EventArgs e)
        {
            if (DisableNavigationSecurity())
            {
                HttpApplication application = (HttpApplication)sender;
                HttpRequest     request     = application.Request;
                HttpResponse    response    = application.Response;

                string loginUrl = ConfigurationManager.AppSettings["LoginUrl"];
                if (loginUrl == null || loginUrl.Trim() == String.Empty)
                {
                    throw new Exception("LoginUrl entry not found in appSettings section of Web.config");
                }

                string errorUrl = ConfigurationManager.AppSettings["ErrorUrl"];
                if (errorUrl == null || errorUrl.Trim() == String.Empty)
                {
                    throw new Exception("ErrorUrl entry not found in appSettings section of Web.config");
                }

                int    i    = request.Path.LastIndexOf("/");
                string page = request.Path.Substring(i + 1, (request.Path.Length - (i + 1)));

                if (page != "WebResource.axd" && page != null)
                {
                    int    j         = loginUrl.LastIndexOf("/");
                    string loginPage = loginUrl.Substring(j + 1, (loginUrl.Length - (j + 1)));

                    int    k         = errorUrl.LastIndexOf("/");
                    string errorPage = errorUrl.Substring(k + 1, (errorUrl.Length - (k + 1)));

                    int    l         = page.LastIndexOf(".");
                    string extension = "";
                    if (page.Length - (l + 1) < 4)
                    {
                        // URL string does not contain a Querystring
                        extension = page.Substring(l + 1, (page.Length - (l + 1)));
                    }
                    else
                    {
                        // URL string may contain a querystring therefore only extract the four characters
                        // that follow the last "."
                        extension = page.Substring(l + 1, 4);
                    }

                    // Only check authority of the page requested is not the login page
                    // Or the error page
                    // And has an .aspx extension
                    if (!(page.Trim().ToUpper().Equals(loginPage.ToUpper())) &&
                        !(page.Trim().ToUpper().Equals(errorPage.ToUpper())) &&
                        (extension.Trim().ToUpper().Equals("ASPX")))
                    {
                        MembershipDAO membershipDAO = new MembershipDAO();
                        if (!new Browser().IsDevice() ||
                            new Browser().IsDevice() &&
                            page.ToLower().Equals("home.aspx"))
                        {
                            page = "%/" + page;
                        }
                        //page = "%/" + page;

                        /**/
                        string applicationName = ConfigurationManager.AppSettings[Definitions.CONFIG_APPLICATION_NAME];

                        if (request.Path.ToLower().Contains("/dashboard/"))
                        {
                            applicationName = ConfigurationManager.AppSettings[Definitions.CONFIG_IHFDASH_APPLICATION_NAME];
                        }
                        /**/

                        if (!membershipDAO.AuthorisedToPage(application.User.Identity.Name, page, applicationName))
                        {
                            if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                            {
                                response.Redirect(request.ApplicationPath + loginUrl + "?ReturnUrl=" + request.Path, true);
                            }
                            else
                            {
                                throw new Exception("Not authorised to page!");
                            }
                        }
                        else
                        {
                            //_log.SaveUserActivity(new UserActivity
                            //{
                            //    AppSystem = (int)ActivityLogEnum.AppSystem.OMS,


                            //});
                        }
                    }
                }
            }
        }
 public void Init(HttpApplication app)
 {
     app.DefaultAuthentication += new EventHandler(OnDefaultAuthentication);
 }
 /// <summary>
 /// Initializes a module and prepares it to handle requests.
 /// </summary>
 /// <param name="context">An <see cref="T:System.Web.HttpApplication" /> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application</param>
 public void Init(HttpApplication context)
 {
     context.BeginRequest += OnBeginRequest;
 }
 /// <summary>Initializes any data/resources on HTTP module start.</summary>
 /// <param name="context">The application context that instantiated and will be running this module.</param>
 public virtual void OnInit(HttpApplication context)
 {
     // put your module initialization code here
 }
示例#47
0
 public void Init(HttpApplication context)
 {
     context.AuthenticateRequest       += Context_AuthenticateRequest;
     context.PostRequestHandlerExecute += Context_PostRequestHandlerExecute;
 }
示例#48
0
 private void SetData(HttpApplication context, RequestFormatCollection data)
 {
     context.Response.SetCookie(new HttpCookie("myGlimpse", Json.Encode(data)));
 }
示例#49
0
    public void OnBeginRequest(object o, EventArgs args)
    {
        HttpApplication app     = (HttpApplication)o;
        var             context = app.Context;
        var             ext     = Path.GetExtension(app.Context.Request.Path.ToLower());

        if ((ext.EndsWith(".jpg") || ext.EndsWith(".png") || ext.EndsWith(".bmp")) && app.Context.Request.Path.StartsWith("/img/s"))
        {
            context.Response.Cache.SetCacheability(HttpCacheability.Public);
            //var pp = app.Context.Server.MapPath(app.Context.Request.Path);
            context.Response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0));

            // if (!System.IO.File.Exists(pp)) return;
            //var lastDate = System.IO.File.GetLastWriteTime(pp);

            // string rawIfModifiedSince = context.Request.Headers.Get("If-Modified-Since");
            // if (string.IsNullOrEmpty(rawIfModifiedSince))
            // {
            //     // Set Last Modified time
            //     context.Response.Cache.SetLastModified(lastDate);
            // }
            // else
            // {
            //     DateTime ifModifiedSince = DateTime.Parse(rawIfModifiedSince);

            //     // HTTP does not provide milliseconds, so remove it from the comparison
            //     if (lastDate == ifModifiedSince)
            //     {
            //         // The requested file has not changed
            //         context.Response.StatusCode = 304;
            //         return;
            //     }
            // }

            Regex pattern = new Regex(@"/img/s(?<imageWidth>\d+)x(?<imageHeight>\d+)/(?<userid>\w+)/img_(?<filename>\w+).(?<ext>\w..+)$");
            Image newImg;
            try
            {
                var    path      = app.Context.Request.Path;
                string localpath = app.Context.Server.MapPath(path);
                _log.Warn(path);
                if (path.StartsWith("/img/s"))
                {
                    Match  match = pattern.Match(path.Replace("-", ""));
                    string m     = "/s" + match.Groups["imageWidth"].Value + "x" + match.Groups["imageHeight"].Value;
                    path      = path.Replace(m, "");
                    localpath = app.Context.Server.MapPath(path);
                    var imgOrigin = Image.FromFile(localpath);

                    int w = int.Parse(match.Groups["imageWidth"].Value);
                    int h = int.Parse(match.Groups["imageHeight"].Value);
                    newImg = ImageHelper.Resize(imgOrigin, w, h, true);

                    MemoryStream mem = new MemoryStream();
                    if (ext == ".png")
                    {
                        newImg.Save(mem, ImageFormat.Png);
                    }
                    else
                    {
                        newImg.Save(mem, ImageFormat.Jpeg);
                    }

                    byte[] buffer = mem.ToArray();
                    app.Context.Response.ContentType = (ext == ".jpg") ? "image/jpg" : "image/png";
                    app.Context.Response.BinaryWrite(buffer);
                    app.Context.Response.Flush();
                    context.Response.Cache.SetLastModified(DateTime.Now);
                    app.Context.Response.End();
                }
                else
                {
                    if (File.Exists(localpath))
                    {
                        //context.Response.StatusCode = 304;
                        //app.Context.Response.Flush();
                        //context.Response.Cache.SetLastModified(System.IO.File.GetLastWriteTime(localpath));
                        //app.Context.Response.End();
                        return;
                    }
                    else
                    {
                        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        context.Response.Cache.SetMaxAge(new TimeSpan(0, 0, 0));
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                context.Response.Cache.SetMaxAge(new TimeSpan(0, 0, 0));
                _log.Error(ex);
                return;
            }
        }
    }
示例#50
0
 private bool Track(HttpApplication context)
 {
     return(context != null && ignoreList.All(p => p != context.Request.RawUrl));
 }
示例#51
0
        /// <summary>
        /// Handles the BeginRequest event of the context control.
        ///
        /// It will execute the following actions:
        ///
        ///     1. Determine which site this request belongs to.
        ///     2. Check if request is for the template.aspx and if it is redirect to the homepage instead.
        ///     3. Determine if it is a folder request or not and if it is detect the default page and redirect.
        ///     4. Restore settings from user cookies.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app     = (HttpApplication)sender;
            HttpContext     context = app.Context;

            // Process only aspx pages and directories
            if (!(context.Request.Url.ToString().ToLower().IndexOf(".aspx") > 0) &&
                !context.Request.Url.ToString().EndsWith("/"))
            {
                // If page name does not contain ".", then assume it is a folder and try to process the request
                if (context.Request.Url.Segments[context.Request.Url.Segments.Length - 1].ToString().Contains("."))
                {
                    return;
                }
            }

            CMSContext ctx = CMSContext.Create(context);

            // Determine SiteId
            SiteDto.SiteRow row = FindSiteFromUrl(ctx);

            // throw does not exist error
            if (row == null)
            {
                //throw new HttpException(404, "Site does not exist");
                Write(null, null, "StoreClosed.htm");
            }

            ctx.SiteId = row.SiteId;

            string appPath = ctx.Context.Request.ApplicationPath;

            if (appPath == "/")
            {
                appPath = String.Empty;
            }

            string outline  = context.Request.RawUrl;
            int    folderId = -1;

            if (ctx.AppPath.Length != 1)
            {
                outline = outline.Substring(ctx.AppPath.Length);
            }

            // Check if the request is for the template.aspx
            if (outline.Equals("/template.aspx", StringComparison.OrdinalIgnoreCase))
            {
                ctx.Redirect(CMSContext.Current.ResolveUrl("~"));
            }

            // If empty, we assume it is the site root that we are requesting
            if (String.IsNullOrEmpty(outline))
            {
                outline = "/";
            }

            // Is it a folder?
            if (outline.EndsWith("/") || !outline.Contains("."))
            {
                using (IDataReader reader = FileTreeItem.GetItemByOutlineAll(outline, CMSContext.Current.SiteId))
                {
                    if (reader.Read())
                    {
                        folderId = (int)reader["PageId"];
                    }

                    reader.Close();
                }
                if (folderId != -1)
                {
                    //try to find default page for folder
                    using (IDataReader reader = FileTreeItem.GetFolderDefaultPage(folderId))
                    {
                        if (reader.Read())
                        {
                            string urlPage = String.Empty;
                            if (context.Request.QueryString.Count > 0)
                            {
                                urlPage = reader.GetString(2) + "?" + context.Request.QueryString;
                            }
                            else
                            {
                                urlPage = reader.GetString(2);
                            }

                            // Add the relative path
                            if (urlPage.StartsWith("/"))
                            {
                                urlPage = "~" + urlPage;
                            }

                            // Redirect
                            ctx.Redirect(CMSContext.Current.ResolveUrl(urlPage));
                        }
                        else
                        {
                            reader.Close();
                            throw new HttpException(204, "Default page for folder not found");
                        }

                        reader.Close();
                    }
                }
            }

            // TODO: remove hard coded cookie names and put it into CMS configuration instead
            HttpCookie cookie;

            //CHECK ToolBar/ToolBox visible
            if (context.Request.Cookies[_toolBarVisibleCookieString] != null)
            {
                cookie = (HttpCookie)context.Request.Cookies[_toolBarVisibleCookieString];
                CMSContext.Current.ToolBarVisible = Convert.ToBoolean(cookie.Value);
            }
            //CHECK ToolBox
            if (context.Request.Cookies[_toolBoxVisibleCookieString] != null)
            {
                cookie = (HttpCookie)context.Request.Cookies[_toolBoxVisibleCookieString];
                CMSContext.Current.ToolBoxVisible = Convert.ToBoolean(cookie.Value);
            }

            //CHECK IsDesignMode
            CMSContext.Current.IsDesignMode = CommonHelper.CheckDesignMode(context);

            //CHECK CULTURE
            string currentCulture = string.Empty;

            //CHECK HIDDEN FIELDS
            if (!String.IsNullOrEmpty(context.Request.Form[_currentCultureRequestString]))
            {
                currentCulture = context.Request.Form[_currentCultureRequestString].Trim();
            }
            else if (!String.IsNullOrEmpty(context.Request.QueryString[_currentCultureRequestString]))
            {
                currentCulture = context.Request.QueryString[_currentCultureRequestString].Trim();
            }

            //CHECK QUERYSTRING
            if (!String.IsNullOrEmpty(context.Request.QueryString[_languageQueryString]))
            {
                currentCulture = context.Request.QueryString[_languageQueryString];
            }
            //CHECK VERSION LANGUAGE
            if (!String.IsNullOrEmpty(context.Request.QueryString[_versionIdQueryString]))
            {
                int LangId    = -1;
                int versionId = int.Parse(context.Request.QueryString[_versionIdQueryString]);
                //get version language id
                using (IDataReader reader = PageVersion.GetVersionById(versionId))
                {
                    if (reader.Read())
                    {
                        LangId = (int)reader["LangId"];
                    }

                    reader.Close();
                }

                //get language name
                using (IDataReader lang = Language.LoadLanguage(LangId))
                {
                    if (lang.Read())
                    {
                        currentCulture = CultureInfo.CreateSpecificCulture(lang["LangName"].ToString()).Name;
                    }

                    lang.Close();
                }
            }

            if (currentCulture != string.Empty)
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(currentCulture);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(currentCulture);
            }
            else
            {
                //CHECK COOKIES
                if (context.Request.Cookies[_currentCultureCookieString] != null)
                {
                    cookie = (HttpCookie)context.Request.Cookies[_currentCultureCookieString];
                    Thread.CurrentThread.CurrentCulture   = new CultureInfo(cookie.Value);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cookie.Value);
                }
                else
                {
                    // culture should be set to the one specified in the web.config file
                    //Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                }
            }

            if (!String.IsNullOrEmpty(currentCulture))
            {
                //ConfigurationManager.AppSettings["HtmlEditorControl"];
                cookie         = new HttpCookie(_currentCultureCookieString);
                cookie.Expires = DateTime.Now.AddMonths(1);
                cookie.Value   = Thread.CurrentThread.CurrentCulture.Name;
                context.Response.Cookies.Add(cookie);
            }
        }
示例#52
0
 public LogUrlEventArgs(HttpApplication httpApplication, string expression)
 {
     HttpApplication = httpApplication;
     Expression      = expression;
 }
示例#53
0
        private void RewriteUrl(HttpApplication app, out string portalAlias)
        {
            HttpRequest  request       = app.Request;
            HttpResponse response      = app.Response;
            string       requestedPath = app.Request.Url.AbsoluteUri;


            portalAlias = "";

            //determine portal alias looking for longest possible match
            String          myAlias = Globals.GetDomainName(app.Request, true);
            PortalAliasInfo objPortalAlias;

            do
            {
                objPortalAlias = PortalAliasController.Instance.GetPortalAlias(myAlias);

                if (objPortalAlias != null)
                {
                    portalAlias = myAlias;
                    break;
                }

                int slashIndex = myAlias.LastIndexOf('/');
                myAlias = slashIndex > 1 ? myAlias.Substring(0, slashIndex) : "";
            } while (myAlias.Length > 0);


            app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri);

            //Friendly URLs are exposed externally using the following format
            //http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx
            //and processed internally using the following format
            //http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx
            //The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config
            string sendTo = "";

            //save and remove the querystring as it gets added back on later
            //path parameter specifications will take precedence over querystring parameters
            string strQueryString = "";

            if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
            {
                strQueryString = request.QueryString.ToString();
                requestedPath  = requestedPath.Replace(app.Request.Url.Query, "");
            }

            //get url rewriting rules
            RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

            //iterate through list of rules
            int matchIndex = -1;

            for (int ruleIndex = 0; ruleIndex <= rules.Count - 1; ruleIndex++)
            {
                //check for the existence of the LookFor value
                string pattern = "^" +
                                 RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[ruleIndex].LookFor) +
                                 "$";
                Match objMatch = Regex.Match(requestedPath, pattern, RegexOptions.IgnoreCase);

                //if there is a match
                if ((objMatch.Success))
                {
                    //create a new URL using the SendTo regex value
                    sendTo = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath,
                                                      Regex.Replace(requestedPath, pattern, rules[ruleIndex].SendTo,
                                                                    RegexOptions.IgnoreCase));

                    string parameters = objMatch.Groups[2].Value;
                    //process the parameters
                    if ((parameters.Trim().Length > 0))
                    {
                        //split the value into an array based on "/" ( ie. /tabid/##/ )
                        parameters = parameters.Replace("\\", "/");
                        string[] splitParameters = parameters.Split('/');
                        //icreate a well formed querystring based on the array of parameters
                        for (int parameterIndex = 0; parameterIndex < splitParameters.Length; parameterIndex++)
                        {
                            //ignore the page name
                            if (
                                splitParameters[parameterIndex].IndexOf(".aspx",
                                                                        StringComparison.InvariantCultureIgnoreCase) ==
                                -1)
                            {
                                //get parameter name
                                string parameterName = splitParameters[parameterIndex].Trim();
                                if (parameterName.Length > 0)
                                {
                                    //add parameter to SendTo if it does not exist already
                                    if (
                                        sendTo.IndexOf("?" + parameterName + "=",
                                                       StringComparison.InvariantCultureIgnoreCase) == -1 &&
                                        sendTo.IndexOf("&" + parameterName + "=",
                                                       StringComparison.InvariantCultureIgnoreCase) == -1)
                                    {
                                        //get parameter delimiter
                                        string parameterDelimiter = sendTo.IndexOf("?", StringComparison.Ordinal) != -1 ? "&" : "?";
                                        sendTo = sendTo + parameterDelimiter + parameterName;
                                        //get parameter value
                                        string parameterValue = "";
                                        if (parameterIndex < splitParameters.Length - 1)
                                        {
                                            parameterIndex += 1;
                                            if (!String.IsNullOrEmpty(splitParameters[parameterIndex].Trim()))
                                            {
                                                parameterValue = splitParameters[parameterIndex].Trim();
                                            }
                                        }
                                        //add the parameter value
                                        if (parameterValue.Length > 0)
                                        {
                                            sendTo = sendTo + "=" + parameterValue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    matchIndex = ruleIndex;
                    break; //exit as soon as it processes the first match
                }
            }
            if (!String.IsNullOrEmpty(strQueryString))
            {
                //add querystring parameters back to SendTo
                string[] parameters = strQueryString.Split('&');
                //iterate through the array of parameters
                for (int parameterIndex = 0; parameterIndex <= parameters.Length - 1; parameterIndex++)
                {
                    //get parameter name
                    string parameterName = parameters[parameterIndex];
                    if (parameterName.IndexOf("=", StringComparison.Ordinal) != -1)
                    {
                        parameterName = parameterName.Substring(0, parameterName.IndexOf("=", StringComparison.Ordinal));
                    }
                    //check if parameter already exists
                    if (sendTo.IndexOf("?" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1 &&
                        sendTo.IndexOf("&" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        //add parameter to SendTo value
                        sendTo = sendTo.IndexOf("?", StringComparison.Ordinal) != -1
                                     ? sendTo + "&" + parameters[parameterIndex]
                                     : sendTo + "?" + parameters[parameterIndex];
                    }
                }
            }

            //if a match was found to the urlrewrite rules
            if (matchIndex != -1)
            {
                if (rules[matchIndex].SendTo.StartsWith("~"))
                {
                    //rewrite the URL for internal processing
                    RewriterUtils.RewriteUrl(app.Context, sendTo);
                }
                else
                {
                    //it is not possible to rewrite the domain portion of the URL so redirect to the new URL
                    response.Redirect(sendTo, true);
                }
            }
            else
            {
                //Try to rewrite by TabPath
                string url;
                if (Globals.UsePortNumber() &&
                    ((app.Request.Url.Port != 80 && !app.Request.IsSecureConnection) ||
                     (app.Request.Url.Port != 443 && app.Request.IsSecureConnection)))
                {
                    url = app.Request.Url.Host + ":" + app.Request.Url.Port + app.Request.Url.LocalPath;
                }
                else
                {
                    url = app.Request.Url.Host + app.Request.Url.LocalPath;
                }

                if (!String.IsNullOrEmpty(myAlias))
                {
                    if (objPortalAlias != null)
                    {
                        int portalID = objPortalAlias.PortalID;
                        //Identify Tab Name
                        string tabPath = url;
                        if (tabPath.StartsWith(myAlias))
                        {
                            tabPath = url.Remove(0, myAlias.Length);
                        }
                        //Default Page has been Requested
                        if ((tabPath == "/" + Globals.glbDefaultPage.ToLowerInvariant()))
                        {
                            return;
                        }

                        //Start of patch
                        string cultureCode = string.Empty;

                        Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalID);
                        if (dicLocales.Count > 1)
                        {
                            String[] splitUrl = app.Request.Url.ToString().Split('/');

                            foreach (string culturePart in splitUrl)
                            {
                                if (culturePart.IndexOf("-", StringComparison.Ordinal) > -1)
                                {
                                    foreach (KeyValuePair <string, Locale> key in dicLocales)
                                    {
                                        if (key.Key.ToLower().Equals(culturePart.ToLower()))
                                        {
                                            cultureCode = key.Value.Code;
                                            tabPath     = tabPath.Replace("/" + culturePart, "");
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        // Check to see if the tab exists (if localization is enable, check for the specified culture)
                        int tabID = TabController.GetTabByTabPath(portalID,
                                                                  tabPath.Replace("/", "//").Replace(".aspx", ""),
                                                                  cultureCode);

                        // Check to see if neutral culture tab exists
                        if ((tabID == Null.NullInteger && cultureCode.Length > 0))
                        {
                            tabID = TabController.GetTabByTabPath(portalID,
                                                                  tabPath.Replace("/", "//").Replace(".aspx", ""), "");
                        }
                        //End of patch

                        if ((tabID != Null.NullInteger))
                        {
                            string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + tabID;
                            if (!cultureCode.Equals(string.Empty))
                            {
                                sendToUrl = sendToUrl + "&language=" + cultureCode;
                            }
                            if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
                            {
                                sendToUrl = sendToUrl + "&" + app.Request.Url.Query.TrimStart('?');
                            }
                            RewriterUtils.RewriteUrl(app.Context, sendToUrl);
                            return;
                        }
                        tabPath = tabPath.ToLowerInvariant();
                        if ((tabPath.IndexOf('?') != -1))
                        {
                            tabPath = tabPath.Substring(0, tabPath.IndexOf('?'));
                        }

                        //Get the Portal
                        PortalInfo portal       = PortalController.Instance.GetPortal(portalID);
                        string     requestQuery = app.Request.Url.Query;
                        if (!string.IsNullOrEmpty(requestQuery))
                        {
                            requestQuery = TabIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = PortalIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = requestQuery.TrimStart('?', '&');
                        }
                        if (tabPath == "/login.aspx")
                        {
                            if (portal.LoginTabId > Null.NullInteger && Globals.ValidateLoginTabID(portal.LoginTabId))
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.LoginTabId + "&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.LoginTabId);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID + "&ctl=login&" +
                                                             requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID + "&ctl=login");
                                }
                            }
                            return;
                        }
                        if (tabPath == "/register.aspx")
                        {
                            if (portal.RegisterTabId > Null.NullInteger)
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.RegisterTabId + "&portalid=" + portalID + "&" +
                                                             requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.RegisterTabId + "&portalid=" + portalID);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID +
                                                             "&ctl=Register&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID +
                                                             "&ctl=Register");
                                }
                            }
                            return;
                        }
                        if (tabPath == "/terms.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Terms&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Terms");
                            }
                            return;
                        }
                        if (tabPath == "/privacy.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Privacy&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Privacy");
                            }
                            return;
                        }
                        tabPath = tabPath.Replace("/", "//");
                        tabPath = tabPath.Replace(".aspx", "");
                        TabCollection objTabs = TabController.Instance.GetTabsByPortal(tabPath.StartsWith("//host") ? Null.NullInteger : portalID);
                        foreach (KeyValuePair <int, TabInfo> kvp in objTabs)
                        {
                            if ((kvp.Value.IsDeleted == false && kvp.Value.TabPath.ToLowerInvariant() == tabPath))
                            {
                                if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID +
                                                             "&" + app.Request.Url.Query.TrimStart('?'));
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID);
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }
示例#54
0
 public void Init(HttpApplication app)
 {
     // register for events created by the pipeline
     app.BeginRequest += new EventHandler(this.OnBeginRequest);
     //app.EndRequest += Application_EndRequest;
 }
示例#55
0
 /// <summary>
 /// 实现接口的Init方法
 /// </summary>
 /// <param name="context"></param>
 public void Init(HttpApplication context)
 {
     context.BeginRequest += new EventHandler(ReUrl_BeginRequest);
 }
 public void Init(HttpApplication application)
 {
     application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
 }
示例#57
0
        public void Init(HttpApplication context)
        {
            var sessionState = ((SessionStateModule)context.Modules["Session"]);

            sessionState.End += SessionEnd;
        }
示例#58
0
 void IHttpModule.Init(HttpApplication context)
 {
     context.BeginRequest        += new EventHandler(this.contextBeginRequest);
     context.AuthenticateRequest += new EventHandler(this.contextAuthenticateRequest);
     context.EndRequest          += new EventHandler(this.contextEndRequest);
 }
示例#59
0
 public void Init(HttpApplication app)
 {
     app.AuthenticateRequest += OnEnter;
 }