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);
}