bool CanServiceRequest(HttpContext context) { //Need to get the object uri first (cannot have query string) string requestUri = GetRequestUriForCurrentRequest(context); string objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri); context.Items["__requestUri"] = requestUri; if (String.Compare(context.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) != 0) { //If the request backed by an existing object if (RemotingServices.GetServerTypeForUri(requestUri) != null) { return(true); } } else { if (context.Request.QueryString.Count != 1) { return(false); } string[] values = context.Request.QueryString.GetValues(0); if (values.Length != 1 || String.Compare(values[0], "wsdl", StringComparison.OrdinalIgnoreCase) != 0) { return(false); } //If the request specifically asks for the wildcard if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { return(true); } // find last index of ? int index = requestUri.LastIndexOf('?'); if (index != -1) { requestUri = requestUri.Substring(0, index); } //If the request backed by an existing object if (RemotingServices.GetServerTypeForUri(requestUri) != null) { return(true); } } //If the request is backed by an existing file on disk it should be serviced if (File.Exists(context.Request.PhysicalPath)) { return(true); } return(false); }
private bool CanServiceRequest(HttpContext context) { string requestUriForCurrentRequest = this.GetRequestUriForCurrentRequest(context); string objectUriFromRequestUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUriForCurrentRequest); context.Items["__requestUri"] = requestUriForCurrentRequest; if (string.Compare(context.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) != 0) { if (RemotingServices.GetServerTypeForUri(requestUriForCurrentRequest) != null) { return(true); } } else { if (context.Request.QueryString.Count != 1) { return(false); } string[] values = context.Request.QueryString.GetValues(0); if ((values.Length != 1) || (string.Compare(values[0], "wsdl", StringComparison.OrdinalIgnoreCase) != 0)) { return(false); } if (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { return(true); } int length = requestUriForCurrentRequest.LastIndexOf('?'); if (length != -1) { requestUriForCurrentRequest = requestUriForCurrentRequest.Substring(0, length); } if (RemotingServices.GetServerTypeForUri(requestUriForCurrentRequest) != null) { return(true); } } return(File.Exists(context.Request.PhysicalPath)); }