If you're not using the upload feature in WebDocumentViewer, you can completely disable it in the following way
ASP.NET
In your WebDocumentRequestHandler.ashx codebehind, add a handler for FileUpload and in that handler, set the e.Cancel = true
C#
public WebDocViewerHandler()
{
this.FileUpload += new FileUploadEventHandler(delegate(object sender, FileUploadEventArgs e) { e.Cancel = true; });
}
VB
Public Sub New()
AddHandler Me.FileUpload, AddressOf fileUploadHandler
End Sub
Private Sub fileUploadHandler(sender As Object, e As FileUploadEventArgs)
e.Cancel = True
End Sub
ASP.NET Core (targeting .NET Framework)
In ASP.NET core (targeting .NET Framework) you need to add a WebDocumentViewerCallbacks class to your startup.cs - which is a bit more involved
c#
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDefaultFiles();
app.UseStaticFiles();
RegisteredDecoders.Decoders.Add(new PdfDecoder() { Resolution = 200 });
app.Map("/wdv", wdvApp => { wdvApp.RunWebDocumentViewerMiddleware(new MyWDVCallbacks()); });
//app.Run(async (context) =>
//{
// await context.Response.WriteAsync("Hello World!");
//});
}
}
public class MyWDVCallbacks : WebDocumentViewerCallbacks
{
public override void DocumentInfoRequested(DocumentInfoRequestedEventArgs args)
{
Console.WriteLine("**********===DocumentInfoRequested===**********");
base.DocumentInfoRequested(args);
}
public override void ImageRequested(ImageRequestedEventArgs args)
{
Console.WriteLine("**********===ImageRequested===**********");
base.ImageRequested(args);
}
public override void FileUpload(FileUploadEventArgs args)
{
args.Cancel = true;
base.FileUpload(args);
}
/*
* The above was just an example of hooking to the two main events.. you can handle any exposed event here
*
* //.. most common ...
* AnnotationDataRequested
* DocumentSave
* DocumentStreamWritten
* AnnotationStreamWritten
* //.. less common .
* PageTextRequested
* PdfFormRequested
* //.. rarely if ever used ..
* ReleaseDocumentStream
* ReleasePageStream
* ResolveDocumentUri
* ResolvePageUri
*/
}