[]
        
(Showing Draft Content)

QuickStart

The steps below describe how to create a simple ASP.NET Core web application that uses GcImageViewer to view image files.

  1. Open Microsoft Visual Studio and select Create a new project | ASP.NET Core Web App and name it. In this example, we have named it as “GcImageViewerApp”.

    quickstart_new.png

  2. Open the project in File Explorer and locate the wwwroot > lib directory.

  3. Open command prompt and run the following command to install GcImageViewer. Make sure that directory location in command prompt is set to lib folder.

    npm install @grapecity/gcimageviewer
  4. Observe that GcImageViewer gets installed at following location:

    GcImageViewerApp\wwwroot\lib\node_modules\@grapecity\gcimageviewer

  5. In Solution Explorer, right click wwwroot folder of the project and select Add > New Item to add a new HTML file named 'index.html'.

    quickstart_index.png

  6. To initialize GcImageViewer and to open an image in the viewer, add the following code to index.html and place the image file to be loaded in the wwwroot folder. In this example, we are using image named sample.jpg.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title>GC Image Viewer Demo</title>
        <script type="text/javascript" src="lib/node_modules/@grapecity/gcimageviewer/gcimageviewer.js"></script>
        <script>
            function loadImageViewer() {
                var viewer = new GcImageViewer("#imageviewer");
                viewer.open("https://i.imgur.com/bvcCEnr.jpeg");
            }
        </script>
    </head>
    <body onload="loadImageViewer()">
        <div id="imageviewer" style=" height:700px"></div>
    </body>
    </html>
  7. To start the application with index.html by default, in Program.cs file, replace the default methods with following code.

    var builder = WebApplication.CreateBuilder(args);
    // Add services to the container.
    builder.Services.AddRazorPages();
    var app = builder.Build();
    // Configure the HTTP request pipeline.
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Error");
    }
    app.UseHttpsRedirection();
    app.UseDefaultFiles();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseAuthorization();
    app.MapRazorPages();
    app.Run();
  8. Build and run the application. A page displaying image in GcImageViewer opens in your default browser.

    quickstart_result.png