Hello guys, welcome to the third session office we don't need a vba tutorial. In this session we will create the our first project and understood it's auto generated code. throughout this series I am going to use Visual Studio 2015. I am opening it. To create a new ASP dotnet VBA project click on the File menu select new project. Within this dialog box, select the resources up under the template and select ASP.
NET web application. I'm going to save this project within the coding directory within our intro and the seal project with dnn v3 hello world. I will upload all of the examples that I created throughout this series on GitHub, so you can easily find it. That's why I am right here v3, which stands for video three. From this dialog box, select the FA BPA and and check the air hosting cloud checkbox and click on the OK button. Take some time depending on your system.
Here is the Our show listen if you work with the ASP dotnet MVC then you are familiar with this the structure which include the controllers models as well as the views for the MVC approach start with the controller controller folder and then the role of the controller whether it was the MVC controller or the API controller, boards controller are different home controller home controller is action from the controller which was present in the system dot web dot MVC dot controller means that this home controller is the MVC controller. Values controller values controller is the action from the EPA controller which was present in the system dot web dot HTTP dot API controller. If you know that this class contains several methods, including the get post, put and delete for the each HTTP verbs Global dot asex files with variety of various configuration for the our application.
One of the most important configuration is the VPA config dot register. Press the cursor on the register and the place fr for go to that definition. This register method is present in the web API. config and this file is present within the app underscore start directory. This higher specify the default routing for the API. routing for VBA and MVC, Aria different MVC routers are so in route or route config.cs file within the app underscore start directory lesson.
So the URI for routing for the very API here is the routing template where the API is the constant term that must be present when we are trying to call the over API. The controller specify the name of the controller, and the ID is the parameter for the method within the our controller. In the next line, we specify that the IDS do have no parameter, so that we can call the method within the controller without specifying the parameter. Let's run our application by pressing the PI we succeed Here is our homepage, who accesses the APA, we need to write the URL so that it matches the routing for the our API. For this we need to write the constant API. Slash is the name of the controller.
Name of the our controller is the values, not that we need to write only values. We does not need to write the controller values and hit the enter button. We can see that the authorization has been denied for the requests. These error occur because we are using the authorized attribute in the our class that we need to remove. I repeated the solisten and reload that page you can see that the value one and value two are written in the form of the JSON. When we have right the APA for class values, it will automatically call the our values controller.
And depending on the HTTP method that you use, it will record the appropriate method. From the browser we can send the get request, so it will access the get method. We have to Ryder get method that is one with the parameter list and one with the parameter. In this case, we cannot specify the nm parameter so that it comes in the parameter list method and written the two strings that are value one and value to if we are specifying the parameter then it will return only a single Let's try we can see that it returned only a single value. In this case, I am using the Microsoft Edge so that it returned the JSON format. If you are working on the Google Chrome or the Mozilla Firefox, then it will return in the XML format.
So don't worry if it look like the different. We're going to copy the same URL and try to open in the Firefox and pasted we can see that it returned in the form of the year XML and remove the parameter. It returned the array of string in the form of XML where a is returned in the form of the ages and what happens if we are trying to access the controller that does not exist? Instead of values I'm going to write the value term only. We can see that it will return the meaningful message that it be resource was not found with the our URL and it's message Italy's and notify was found to match the controller. In this lesson we created our first VBA and call it cat methods.
To create a new project open the Visual Studio. From the file new project template select the images of ASP dotnet web application and the VPP directory structure where fish are off VBA is similar to the MVC model content the all of the model controller contain the both MVC as well as the PA controller global dot ASX file content da configure Listen, pay VBA config.cs file contain the routing for the our web API and route config.cs file contain the routing for the MVC. If you have any doubt, feel free to ask the question. Thank you for listening. Have a nice day.