im using awesomium and vb.net as a client side application for my web application. Can anyone say me how to cancel a request when a url contain a specific key word. for example , if my url contains view , then i need to cancel the request and download the pdf to local machine and view it with client pdf viewer. i had done the second part but i dont know how to cancel the the request.
using vb.net native webcontrol i have navigating event . but what it the event equivalent to this in awesomium
below is the code im using
Public Class ResourceInterceptor Implements IResourceInterceptor
Public Function OnFilterNavigation(ByVal request As NavigationRequest) As Boolean Implements IResourceInterceptor.OnFilterNavigation
If request.Url.ToString.Contains("ViewPdf") Then
Path = ExtractPath(request.Url.ToString)
openpdf(Path)
Return False ' Cancel the request.
Else
System.Diagnostics.Process.Start(request.Url.ToString)
Return True
End If
End Function
Public Function OnRequest(ByVal request As ResourceRequest) As ResourceResponse Implements IResourceInterceptor.OnRequest
Return Nothing
End Function
End Class
Can any one say how to cancel a request when a url contain a specified text
Implement the Awesomium.Core.IResourceInterceptor
interface and attach it to your webcore session with WebCore.ResourceInterceptor = new ResourceInterceptor();
Here is a simple ResourceInterceptor in C#.
using System;
using System.IO;
using System.Reflection;
using Awesomium.Core;
namespace MyApp
{
public class ResourceInterceptor : IResourceInterceptor
{
/// <summary>
/// Not used.
/// </summary>
public virtual ResourceResponse OnRequest(ResourceRequest request)
{
return null;
}
/// <summary>
/// Optionally blocks any web browser requests by returning true when the URL contains "/view/".
/// </summary>
public virtual bool OnFilterNavigation(NavigationRequest request)
{
return String.Contains(request.Url.AbsolutePath, "/ViewPdf/", StringComparison.InvariantCultureIgnoreCase);
}
}
}