Esempio n. 1
0
        internal void InitValidateInternal()
        {
            string verb = Verb;

            // Remove all spaces from verbs before wildcard parsing.
            //   - We don't want get in "POST, GET" to be parsed into " GET".
            verb = verb.Replace(" ", String.Empty);     // replace all " " with String.Empty in requestType

            _requestType = new Wildcard(verb, false);   // case-sensitive wildcard
            _path        = new WildcardUrl(Path, true); // case-insensitive URL wildcard

            // if validate="false" is marked on a handler, then the type isn't created until a request
            // is actually made that requires the handler. This (1) allows us to list handlers that
            // aren't present without throwing errors at init time and (2) speeds up init by avoiding
            // loading types until they are needed.

            if (!Validate)
            {
                _type = null;
            }
            else
            {
                _type = ConfigUtil.GetType(Type, "type", this);

                if (!ConfigUtil.IsTypeHandlerOrFactory(_type))
                {
                    throw new ConfigurationErrorsException(
                              SR.GetString(SR.Type_not_factory_or_handler, Type),
                              ElementInformation.Source, ElementInformation.LineNumber);
                }
            }
        }
        internal void InitValidateInternal()
        {
            string pattern = this.Verb.Replace(" ", string.Empty);

            this._requestType = new Wildcard(pattern, false);
            this._path        = new WildcardUrl(this.Path, true);
            if (!this.Validate)
            {
                this._type = null;
            }
            else
            {
                this._type = ConfigUtil.GetType(this.Type, "type", this);
                if (!ConfigUtil.IsTypeHandlerOrFactory(this._type))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { this.Type }), base.ElementInformation.Source, base.ElementInformation.LineNumber);
                }
            }
        }
        internal HandlerMapping(String requestType, String path, String typeName, bool defer)
        {
            // Remove all spaces from verbs before wildcard parsing.
            //   - We don't want get in "POST, GET" to be parsed into " GET".
            requestType = requestType.Replace(" ", "");      // replace all " " with "" in requestType

            _requestType = new Wildcard(requestType, false); // case-sensitive wildcard
            _path        = new WildcardUrl(path, true);      // case-insensitive URL wildcard

            // if validate="false" is marked on a handler, then the type isn't created until a request
            // is actually made that requires the handler. This (1) allows us to list handlers that
            // aren't present without throwing errors at init time and (2) speeds up init by avoiding
            // loading types until they are needed.

            if (defer)
            {
                _type     = null;
                _typename = typeName;
            }
            else
            {
                _type = Type.GetType(typeName, true);

                if (!IsTypeHandlerOrFactory(_type))
                {
                    throw new HttpException(HttpRuntime.FormatResourceString(SR.Type_not_factory_or_handler, typeName));
                }

                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted))
                {
                    if (IsTypeFromAssemblyWithStrongName(_type) && !IsTypeFromAssemblyWithAPTCA(_type))
                    {
                        throw new HttpException(HttpRuntime.FormatResourceString(SR.Type_from_untrusted_assembly, typeName));
                    }
                }
            }
        }