Exemple #1
0
        /*
         * Compile an .ascx file into a UserControl derived Type
         */
        internal static Type GetCompiledUserControlType(string virtualPath,
                                                        string inputFile, HttpContext context)
        {
            CheckUserControlFileExtension(virtualPath);

            // We need unrestricted permission to process the UserControl file
            InternalSecurityPermissions.Unrestricted.Assert();

            UserControlParser parser = new UserControlParser();

            Type t = null;

            // Suspend client impersonation (for compilation)
            HttpContext.ImpersonationSuspendContext ictx = context.Impersonation.SuspendIfClient();

            try {
                try {
                    t = parser.GetCompiledType(virtualPath, inputFile, context);
                }
                finally {
                    // Resume client impersonation
                    ictx.Resume();
                }
            }
            catch { throw; } // Prevent Exception Filter Security Issue (ASURT 122835)

            return(t);
        }
        /*
         * Compile an .aspx file into a Page object
         */
        /// <include file='doc\PageParser.uex' path='docs/doc[@for="PageParser.GetCompiledPageInstance"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static IHttpHandler GetCompiledPageInstance(string virtualPath,
                                                           string inputFile, HttpContext context)
        {
            // Only allowed in full trust (ASURT 123086)
            InternalSecurityPermissions.UnmanagedCode.Demand();

            // Suspend client impersonation (ASURT 139770)
            HttpContext.ImpersonationSuspendContext ictx = context.Impersonation.SuspendIfClient();

            try {
                try {
                    return(GetCompiledPageInstanceInternal(virtualPath, inputFile, context));
                }
                finally {
                    // Resume client impersonation
                    ictx.Resume();
                }
            }
            catch { throw; } // Prevent Exception Filter Security Issue (ASURT 122835)
        }