The first action jump mode is as follows:
- Redirecttoaction ("index");//A parameter is not passed in under this controller.
- Redirecttoaction (Actionname,controllername)//can jump directly to another controller.
- Redirecttoroute (New {controller= "home", action= "Index"});//can jump to other controller
- Redirecttoroute (New {controller= "home", action= "index", Id=param});//can jump to other controller with parameters.
- Response.Redirect ("index?id=1"), or//for the method name under this controller, can be taken with parameters.
- Return Redirect ("index");//Applies to the name of the method under this controller.
- Return view ("index"); Direct display of the corresponding page does not pass the controller's method.
- Return view ("~/views/home/index.aspx");//This method is to write the full path, directly display the page, without the Controller method
- return view ()//display the page directly without the Controller method
Jump Direct write full path record in view/home/index?msg=11
Example: Redirecttoaction ("Index", "Home", new {msg= "Operation succeeded", name= "admin"});
Then, if you receive parameters directly in the action method, index (string msg,string name), you can get the arguments passed in, and if you don't want to receive them, use the following method.
- If you are using the original Index?msg=11&name=simmer then you can use request.querystring["MSG"), then the view is @request.querystring["MSG"]
- You can use html.viewcontext.routedata.values["MSG" If you are using the routing mechanism of the parameter Index/11/simmer or request.requestcontext.routedata.values["MSG"]
The arguments in MVC and get in view