Challenge 6 – MVC 5 ASP.net C# Controller method to handle JSON request
To perform effectively as a C# software application developer, one must be acquainted with various facets of the C# programming language. To test the skills of application developers, Superior Consulting Services (SCS) offers a series of technical coding challenges designed to challenge and educate C# application developers. This challenge addresses C# basics and presents SCS’ sixth challenge: MVC 5 ASP.net C# Controller method to handle JSON request.
Let’s get ready to rumble… C# style
Each SCS challenge will require the user to solve a problem and present their approach through a coded solution. All questions are designed to be solvable by mid-level C# application developers in one hour or less.
An application’s user interface needs to populate an HTML Select element based upon selection of a data element in another HTML Select element. The selection, in string format, is sent to the server. The server responds with a list of strings in which to populate the select box.
This challenge will involve writing a C# Controller method that will handle a response from a JSON formatted web request from a Razor View Page and returning the appropriate response, a list of strings, back to the web page. The request is generated from an html Change event generated from a Select element.
The controller method must handle the JSON formatted request which passes a string to the controller method. The method must then take the submitted string, perform a database operation, and return the result (list of strings) in JSON format, back to the Web Page. The database operation is NOT part of the challenge.
The following code supports this challenge.
- Razor View Page JQuery Snippet which sends data to Controller.
- Controller method template, which MUST be completed to meet the challenge.
Razor View Page JQuery Snippet
The following is an AJAX and JQUERY embedded C# Razor View Page which submits the request to the controller.
Controller Method Template
The challenge will involve embellishing the following ASP.NET MVC 5 controller method.
- The ASP.NET MVC 5 controller method must be written in C# and contain all appropriate attribution, decoration, typing, and punctuation. Please use the Controller method template above as a starting point. Do NOT need to define or embellish the _bidMapper.GetString method.
- When embedded into a C# application, the method must compile, build and run without errors or warnings.
- Contestant challenge submittals should be emailed to email@example.com, Subject Line SCS Coding Challenge #6.
- Reponses to Challenge #6 should be received by 5:00 pm CDT, August 31 , 2015
In the event of a tie between two or more winning solutions, the first solution received will receive the prize; however, all submitters with correct solutions will be recognized.
- Employees of SCS are not eligible to participate in the coding challenge.
The best solution submitted will receive an Amazon gift certificate worth $25.00 and have the winning solution, along with the winner’s name, on the SCS website: www.teamscs.com.