Taurus. MVC 2.0 open-source release: WebAPI development tutorial, taurus. mvcwebapi
Background:
Some users have reported that Tausus. MVC can write webapis?
Yes!
What about the tutorial?
Well, Mu you!
Okay, just 2.0 is coming out, so we will bring the WEBAPI tutorial!
Open Source Address:
Https://github.com/cyq1162/taurus.mvc
The following is a tutorial:
Step 1: Create an ASP. NET Web application: WebAPI Project
Step 2: Reference Taurus. MVC on Nuget
After installation, the Framework introduces two Taurus. Core. dll and CYQ. Data. dll by default, and automatically configures web. config.
Step 3: Create a new Controller class to write programs and inherit from Taurus. Core. Controller
Step 4: modify web. config and run F5
Run F5. If this error is reported:
Just comment out the Classic Mode of httpModules:
Continue to run F5 and find that this prompt is correct:
If the path cannot be found, defacontroller controller is located. The system prompts that defacontroller controller does not exist.
We have defined a UserController and the routing mode is 1, so our access address is:
Get it done, close the job!
In five minutes, a high-performance WebAPI is ready!
Step 5: Process permission Verification
If you only provide interfaces and do not perform permission verification, the steps above are complete.
If the API requires permission verification, this step is skipped.
1: Create defacontroller controller and define and implement the CheckToken method (the agreed method is defined as follows :)
public static bool CheckToken(IController controller, string methodName)
2: add the Token attribute to the Controller class or method that requires permission verification.
Run again and check the result:
Work done!
3. Other questions:1: Where can I provide a Token?
Based on the business environment: open a GetToken method under a Controller.
2: What is the complete implementation of CheckToken?
Based on the business environment: Use your own GetToken method to implement your own CheckToken verification.
3: What is the performance?
The request is about 10 ms, which is very simple in addition to brute-force and efficient.
4: Is. net Core supported?
It is expected to be supported when the. net core version is released and can be upgraded seamlessly.
Summary:
You have the value!
Next, we have to switch the thread back to continue writing the Aries tutorial!