ASP. net mvc transmits parameters to the server, asp. netmvc

Source: Internet
Author: User

ASP. net mvc transmits parameters to the server, asp. netmvc

ASP. net mvc transmits parameters to the server. You can refer to and use methods that suit your needs for frontend and server writing. When you pass only one or two parameters, you may feel that there is nothing. If there are many parameters in a method, you can consider the model, and the front-end can consider the object. In this way, you can compare it with the attribute name of the model, good maintenance and fewer errors.

All the following demos are performed in the ASP. net mvc environment.

In the controller, create two actions. The second Action is a method with four parameters. In a normal development environment, you have to write several parameters if you have several parameters.


In the view, you need to pass the value entered or selected by the user to the Post1 () method of Action.

 
In the preceding code example, the highlighted part is transmitted using four parameters and json.

The result is returned after processing by the server:



If you have some knowledge about javascript objects, you can also write as follows:


After the modification, the execution results are the same. It only applies the javascript Object form. Now that it is in the ASP. net mvc environment, I should think of a Model. We can write the passed parameters as a Model.

This mainly solves the problem of the Controller's Action parameters. If there are many parameters, the more parameters the Action carries. In case of method overloading, You have to match multiple actions. If you use the Model, you do not need to care about the number of parameters. You only need to use the model as the parameter.

Create a model:



Then in the controller, you can write it:

 


Multiple transfer methods for aspnet mvc Parameters

What do you mean ??
Receive it directly in the Controller, right?
Public ActionResult Index (string id, strin page)
That's all.
You can also use Request. QueryString or Request. Form []

How does aspnet mvc check the types of uploaded files on the server and client respectively?

1. Client. The client mainly analyzes the file name string and determines its extension. Javascript does not seem to be able to directly access files on the client. If you have a better solution, please contact us.
2. server side. By analyzing the binary stream of a file, the server verifies the information in the file header to avoid malicious uploading by modifying the file name suffix.

There is a lot of information above, and it cannot be put down here. Baidu is just ready ~
 

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.