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.

  1. Visual Studio

Create the Project

  1. Open Visual Studio
  2. Select Create new project… (File / New / Project)
  3. Expand Visual C# and select Web.
  4. Select ASP.NET Web Application (.NET Framework)
  5. Set the Name for your ScriptLink project. (e.g., SLSDemo.Web)
  6. Accept defaults for your Location and Solution name.
  7. Set the Framework to .NET Framework 4.7.2.
  8. Select OK.
  9. On the New ASP.NET Web Application screen,
  10. Select Empty.
  11. Check Add unit tests
  12. Select OK.
  13. The project will now be created.

Add Required Packages

  1. Right-click on the solution and select Manage NuGet Packages for Solution…
  2. Enter ScriptLinkStandard in the search box. (Check Include prerelease to check to get the latest prelease version.)
  3. Select ScriptLinkStandard from the search results.
  4. Check the boxes next to each of your projects (Web and Unit Test) and select Install.
  5. Once installed you may close the NuGet - Solution page or search for additional packages.

Create Controller API

  1. Right-click on the SLSDemo.Web project and select Add / New Folder…
  2. Set the name of the folder to Api.
  3. Right-click on the Api folder and select New / Web Service (ASMX).
  4. Set the Item name to ScriptLinkController and select OK.
  5. 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";
     }
    }
    
  6. Add to the top of the file.
    using ScriptLinkStandard.Objects;
    
  7. 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!");
     }
    }
    
  8. Right-click on the project and select Add / HTML Page
  9. Set the Item name to index and select OK.
  10. Run the project.
  11. You should now see a blank web page rendered from http://localhost:{portnumber}/index.html
  12. Replace index.html with Api/ScriptLinkController.asmx and press Enter.
  13. Congratulations! You should now see your Web Service default documentation.
  14. Select Service Description to see the WSDL.
  15. Select GetVersion to view documentation on the GetVersion method. 1. Select Invoke to see the version number you set returned.
  16. Select RunScript to view documentation on the RunScript method.