The framework provided by MVC in Microsoft is now only found to be ASP. Another 8 years ago, I made an MVC Windows app framework if interested I will introduce to you in the future, welcome everyone's attention. MVC concept on the site there are a lot of people go to look must be able to see, here do not repeat the story. Here is just a description of how to add.
1. Locate the ASP. NET project, then go to the Controller folder, right-expand menu [Add] to expand the next Level menu, then select [Controller].
2. There are 3 options in the dialog box, this time to express the convenience of the first empty MVC5 controller
3. Fill in the name of the controller and click Add.
It is important to note that the controller is the necessary end. This is the MVC framework for routing.
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using SYSTEM.WEB.MVC;
Namespace Webmvcapp.controllers
{
public class Reqordercontroller:controller
{
Get:reqorder
Public ActionResult Index ()
{
return View ();
}
}
}
The newly created CS file is similar to this.
3. Write a simple example of adding a welcome method to the controller's code
Get:reqorder
public string Welcome ()
{
Return "This was app for request Order submit.";
}
This code returns a string of characters as soon as the welcome of the controller is called. Similar to the output of HelloWorld.
4. You can test it by F5.
It's not the same as it was written, right, the current page is the default page, and there is no controller processing location just written.
5. Test controller
Add the Controller and the methods that need to be tested in the service portal.
The page that is displayed is just the thought.
Unlike other web pages, the return is really just a string, not an HTML page, you can use the right-click menu to look at the code.
Summarize
1.Controller must have "Controller" at the end of the new, you need to pay attention to casing specifications Oh.
2. When the controller is called, the address of the page access, the server root address, the controller's name does not contain the controller part, and then add the method name.
#补充:
- I have seen the API data, in the public number configuration, you need to verify that the server-side address is configured correctly, will be the configured address to call the Web page, and then ask the server to reply
Rebuilding programmer Power (3)-asp.net MVC Framework Add controller