"ASP." Add controllers and views

Source: Internet
Author: User

Controller controllers

Before adding the controller, let's take a look at some of the controllers that we've automatically generated for us, and we'll look at AccountController.cs.

Look at the login authentication method login

!!! Does it look like a lot of different things in the past? What is async supposed to do with async? What is task<iactionresult>? var result = await _signinmanager.passwordsigninasync (model. Email, model. Password, model. RememberMe, lockoutonfailure:false);?

A lot of problems, have not been so used before, hurriedly mend.

Suddenly found the blog Park two years ago article, gradually clear up.


Practical case: Implementing parallelism in existing code through ASYNC/AWAIT


Async & await Past life (Updated)

Do you know what happened after reading these two articles? This diagram, in particular, gives us a clear picture of its sequence of operations:

OK, the level is limited, I just read a half understand, know is why, why do so, as to the principle and application, when the use of the time again bad to fill it ... Sunglass (@@facesymbol@@ㄟ) ha

Let's add a controller Helloworldcontroller

View views

We add the view (no longer the right click to add a view as we did before.) I think that's better. Create a controller directly generate the corresponding Views folder, which we need to create manually)

We create a new folder under the Views folder HelloWorld the same name as our controller.

Right-click this folder and we find that the Add option has a view

This interface is the same as we did before, but we do not have a data model, model classes and data on-line text class does not choose to create

So, let's change the way we right click folder → add → new Item Select MVC View page Our Controller action is index so use the default index.cshtml.

Let's modify this view page to remove the comment and add the title

The default is to use the _layout layout page (_viewstart.cshtml), of course, as before, we can not use the default layout page _layout, in index.cshtml to modify the layout of their own page layout= "_layouttest";

Routing configuration in the Satrtup.cs class

Let's run a look.

Passing Data

We receive two parameters name (name) and nums (number of outputs)

Pass to the view page via ViewData

We are trying to receive these two parameters on the page and output:

Let's look at the results of the output:

it seems to be very easy to use, and not much difference before, it is estimated that has not gone to the essence of the place, more and more a kind of anxious appearance, but after all, the online information is too little, or need our own slowly study found, we discuss the study together.

The first use of core, basically is to collate the information on the Internet, have not studied before, I hope that with all the research, if there are errors, I hope you correct, if you do not understand the place also hope that you point.

Original article reproduced please respect the fruits of labor http://yuangang.cnblogs.com

"ASP." Add controllers and views

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.