Walkthrough: Create a New ScriptLinkStandard Project
This walkthrough uses Visual Studio 2017 and C#.
Before You Begin
You will need the following to complete this walkthrough.
- Visual Studio
Create the Project
- Open Visual Studio
- Select Create new project… (File / New / Project)
- Expand Visual C# and select Web.
- Select ASP.NET Web Application (.NET Framework)
- Set the Name for your ScriptLink project. (e.g., SLSDemo.Web)
- Accept defaults for your Location and Solution name.
- Set the Framework to .NET Framework 4.7.2.
- Select OK.
- On the New ASP.NET Web Application screen,
- Select Empty.
- Check Add unit tests
- Select OK.
- The project will now be created.
Add Required Packages
- Right-click on the solution and select Manage NuGet Packages for Solution…
- Enter ScriptLinkStandard in the search box. (Check Include prerelease to check to get the latest prelease version.)
- Select ScriptLinkStandard from the search results.
- Check the boxes next to each of your projects (Web and Unit Test) and select Install.
- Once installed you may close the NuGet - Solution page or search for additional packages.
Create Controller API
- Right-click on the SLSDemo.Web project and select Add / New Folder…
- Set the name of the folder to Api.
- Right-click on the Api folder and select New / Web Service (ASMX).
- Set the Item name to ScriptLinkController and select OK.
- You should now have a basic Hello World web method created.
public class ScriptLinkController : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } }
- Add to the top of the file.
using ScriptLinkStandard.Objects;
- Replace the HelloWorld() web method with the following.
public class ScriptLinkController : System.Web.Services.WebService { [WebMethod] public string GetVersion() { return "v.0.0.1"; } [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject2015, string parameters) { return optionObject2015.ToReturnOptionObject(ErrorCode.Info, "Hello, World!"); } }
- Right-click on the project and select Add / HTML Page
- Set the Item name to index and select OK.
- Run the project.
- You should now see a blank web page rendered from http://localhost:{portnumber}/index.html
- Replace index.html with Api/ScriptLinkController.asmx and press Enter.
- Congratulations! You should now see your Web Service default documentation.
- Select Service Description to see the WSDL.
- Select GetVersion to view documentation on the GetVersion method. 1. Select Invoke to see the version number you set returned.
- Select RunScript to view documentation on the RunScript method.