forge-viewmodels
forge-viewmodels copied to clipboard
View models from listof buckets and objects: This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2-Legged Token
View Models (.NET Core C#)
Description
This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2 Legged OAuth. The front-end was desiged with pure HTML + JavaScript (jQuery, Bootstrap), no ASPx features (i.e. no WebForms or MVC on this sample). It includes: create and delete buckets, upload and delete object, translate (including .zip files). This code is based on this tutorial.
Thumbnail
![]()
Setup
Prerequisites
- Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
- Visual Studio: Either Community 2017+ (Windows) or Code (Windows, MacOS).
- .NET Core basic knowledge with C#
- JavaScript basic knowledge with jQuery
- ngrok: Routing tool, download here
Running locally
Clone this project or download it (this netcore branch only). It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):
git clone github.com/Autodesk-Forge/model.derivative-WebAPI-sample.git
Visual Studio (Windows):
Right-click on the project, then go to Debug. Adjust the settings as shown below.

Visual Sutdio Code (Windows, MacOS):
Open the folder, at the bottom-right, select Yes and Restore. This restores the packages (e.g. Autodesk.Forge) and creates the launch.json file. See Tips & Tricks for .NET Core on MacOS.

At the .vscode\launch.json, find the env vars and add your Forge Client ID, Secret and callback URL. Also define the ASPNETCORE_URLS variable. The end result should be as shown below:
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS" : "http://localhost:3000",
"FORGE_CLIENT_ID": "your id here",
"FORGE_CLIENT_SECRET": "your secret here",
"FORGE_WEBHOOK_URL": "your ngrok address here: e.g. http://abcd1234.ngrok.io",
},
Run ngrok http 3000 to create a tunnel to your local machine, then copy the address into the FORGE_WEBHOOK_URL environment variable.
Deployment
To deploy this application to Heroku. After clicking on the button below, at the Heroku Create New App page, set your Client ID and Secret for Forge.
Further Reading
Documentation:
Tips & Tricks
This sample uses .NET Core and works fine on both Windows and MacOS, see this tutorial for MacOS.
Troubleshooting
-
error setting certificate verify locations error: may happen on Windows, use the following:
git config --global http.sslverify "false" -
Using Visual Studio 2015 (or older): unfortunately this version is not supported.
License
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Written by
Augusto Goncalves @augustomaia, Forge Partner Development