0.5.12 Building a URL From User Input

A Program Can Combine Input With a URL

In the previous activity, you saw that a URL can include query information.

A C# program can take information supplied by a user and use it to build the URL that will be opened in a browser.

For the FIT weather activity, the important flow is:

Activity diagram showing user information, then C# string value, then URL text, then browser request.
UserInformation.
  • New
  • Changed
  • Removed

The goal is not to build a complete web application.

It is to trace how one piece of information becomes part of a web request.

Begin With a String Value

Assume the supplied course application has already made a user's location available as text.

Conceptually:

string location = userInput;

The exact control or source that supplies userInput is part of the supplied application.

You do not need to redesign the user interface.

Focus on the value itself.

If the learner entered:

Activity diagram showing Get user information, then Represent it as text, then Build the required URL, then Pass the URL to the browser-opening step.
GetUserInformation.
  • New
  • Changed
  • Removed

This activity is about constructing the request destination.

The next activity focuses on what happens when the C# application asks the browser to display it.