WebView.WebResourceRequested WebView.WebResourceRequested WebView.WebResourceRequested WebView.WebResourceRequested Event

Definition

Occurs when an HTTP request has been made.

public : event TypedEventHandler<WebView, WebViewWebResourceRequestedEventArgs> WebResourceRequested
// Register
event_token WebResourceRequested(TypedEventHandler<WebView, WebViewWebResourceRequestedEventArgs> const& handler) const;

// Revoke with event_token
void WebResourceRequested(event_token const& cookie) const;

// Revoke with event_revoker
WebResourceRequested_revoker WebResourceRequested(auto_revoke_t, TypedEventHandler<WebView, WebViewWebResourceRequestedEventArgs> const& handler) const;
public event TypedEventHandler<WebView, WebViewWebResourceRequestedEventArgs> WebResourceRequested
Public Event WebResourceRequested As TypedEventHandler (Of WebView, WebViewWebResourceRequestedEventArgs)
<WebView WebResourceRequested="eventhandler"/>

Examples

This example demonstrates how to intercept request for a specific domain generate an alternate response.

Uri _myUri = new Uri("http://www.contoso.com");

void InterceptWebRequest(WebView sender, WebResourceRequestedEventArgs args)
{
    if (_myUri.IsBaseOf(args.Request.RequestUri))
    {
        args.Response = GenerateResponse(args.Request);
    }
}

HttpResponseMessage GenerateResponse(HttpRequestMessage request)
{
    // ...
}

Remarks

This event occurs after the HTTP request has been made. You can use this event to intercept the response before it's processed by the WebView.