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 ~