NFinal controller-URL, nfinal controller url

Source: Internet
Author: User

NFinal controller-URL, nfinal controller url
URL routing rules

Rule: http: // URL/Module name/controller relative path file name/example name .htm

Example: http: // localhost/App/IndexController/Index.htm
Http: // localhsot/App/Admin/IndexController/Index.htm

Passing Parameters

Http: // URL/Module name/controller relative path file name/function name/parameter name 1/parameter value 1/.../parameter name N/response value n.htm

Example: http: // localhost/App/IndexController/Index/id/1.htm
Http: // localhost/App/ListController/Index/pageSize/5/pageIndex/1.htm

Obtain URL parameters

Add some parameters to the Controller method, such as user, and then output.

1 using System; 2 using System. collections. generic; 3 using System. web; 4 namespace WebMvc. app. controllers 5 {6 public class SampleController: Controller 7 {8 public void Show (string user) 9 {10 Write (string. format ("Hello {0 }. ", user); 11} 12} 13}Controller Code

Run WebCompiler. aspx to regenerate.
The Web/Default/SampleControler folder is included in the project.
The Show. cs code is as follows:

1 using System. collections. generic; 2 using System. web; 3 namespace WebMvc. app. web. default. sampleController 4 {5 public class ShowAction: Controller 6 {7 public ShowAction (System. IO. textWriter tw): base (tw) {} public ShowAction (string fileName): base (fileName) {} 8 public void Show (string user) 9 {10 Write (string. format ("Hello {0 }. ", user); 11} 12} 13}Show. cs Code

Modify the URL in show.html

URL: http: // localhost/App/SampleController/Show/user/Lucas.htm

In show.html, the Code is as follows:

1 The browser outputs Hello Lucas.

Parameter description

NFinal will automatically help you convert the parameter types you need, but you must ensure that the parameter names are consistent before and after,
Parameters in the function can obtain not only the parameters in the URL, but also the parameters in POST.
But NFinal does not support obtaining? Id = 1.
The parameter type can be int, string, float, or other basic types.

Of course, the built-in _ get variable of Controller can also be obtained and converted manually like the traditional ASPX variable.
For example, string user = _ get ["user"];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.