Tech Junkie Blog - Real World Tutorials, Happy Coding!: ACME Bank: Step 6: Running Your Asp.Net Core Application For The First Time

Thursday, July 8, 2021

ACME Bank: Step 6: Running Your Asp.Net Core Application For The First Time

Before we run our Asp.Net Core application for the first time we are going to copy a controller from Asp.Net Core 2.2 to help us create the skeleton for our application.  A skeleton are the plumbings we do at the beginning of our application to make sure all the mechanisms work.  It's called the ValuesController which has been replaced with a more complicated WeatherForecastController.  The ValuesController is just a lot easier to work with to get things set up.


Just create a new controller in the "Controllers" and call it "ValuesController.cs" Here is the code for it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace ACMEBank.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public ActionResult> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public ActionResult Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody] string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}

As you can see it's pretty basic.

Before we run our application for the first time we want to comment out the redirect https and keep our application in http mode in the beginning so that it's easier to work with. We also need to remove the https port in the launchSettings.json file, in Properties/launchSettings.json

Here is where you comment out the https redirect in the Startup.cs file

       // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

        {

            if (env.IsDevelopment())

            {

                app.UseDeveloperExceptionPage();

            }



            // app.UseHttpsRedirection();



            app.UseRouting();



            app.UseAuthorization();



            app.UseEndpoints(endpoints =>

            {

                endpoints.MapControllers();

            });

        }

Here is the change in launchSettings.json, make sure you remove the https: portion of the URL in the last configuration and just leave the http://localhost:5000

    "ACMEBank.API": {

      "commandName": "Project",

      "launchBrowser": true,

      "launchUrl": "weatherforecast",

      "applicationUrl": "http://localhost:5000",

      "environmentVariables": {

        "ASPNETCORE_ENVIRONMENT": "Development"

      }

Now you are ready to run the Asp.Net Core api by openning a terminal session and type dotnet run

Just open up the browser and browse to http://localhost:5000/api/values we would get the values from our HttpGet method of the ValuesController








Congratulation! You've just created your first API!

Previous: ACME Bank: Step 5: Setup Visual Code For C# Development With Extensions

Next: Add A Dev User In MySQL

28 comments:

  1. Your blog is very informative, finally, I found exactly what I want. Paypal is an excellent service for online payments but lots of its users confront issues while they access Paypal. If you want to resolve your problems then must visit Paypal contact Nederland.

    ReplyDelete
  2. Your blog is very informative and interesting to read, finally, I found exactly what I searching for. There are lots of users of Macfee antivirus in the world because of its features and easy interface. If you want to explore more interesting facts about Mcafee antivirus or want to resolve your technical issues then must visit Mcafee klantenservice nummer.

    ReplyDelete
  3. We’re a leader in electrical, lighting, and sign installation, manufacturing and repair services for commercial and industrial marketplace to address all your electrical needs. Visit our website to learn more!

    ReplyDelete
  4. Studio by TCS showcases carefully curated collections from an array of Pakistani designers and brings the best of Pakistani fashion to your doorstep. With the unparalleled strength and reliability of TCS’s logistics platform, Studio by TCS provides a seamless customer experience. We serve you with the same unflinching commitment to quality and customer service that has set TCS apart as a market leader for 34 years. With an eye on the future, Studio by TCS defines fashion in the digital age. Join us as we take Pakistani fashion global.

    ReplyDelete
  5. They can disrobe before you. If you need to recruit them for joy by blending with prominent Call Girls in Chanakyapuri, you can appreciate the night with a solitary call or WhatsApp message. On the off chance that you are frugal yet need to appreciate pleasurable closeness proceed to visit the spot while our agency furnish you with respectable and proficient Call Girls in Chanakyapuri to excite your remain. Our escort agency, Chanakyapuri Call Girls have connections to Call Girls in Chanakyapuri with the most blazing, sizzling and enchanting highlights. At long last, we know about some deceitful demonstrations submitted by most Call Girls in Chanakyapuri. You are really supposed to go for Call Girls in Chanakyapuri if you really want to have the best escort. You will surely be astonished to explore their natural beauty and looks. The Call Girls in Chanakyapuri always thinks of their clients.

    ReplyDelete
  6. We have actual scenarios that cause your purpose to double or treble. An escort maidservant is your partner for every action you want to do with them, similar to the Escorts Service in Chanakyapuri do. For your convenience, Eager for any of this young lady’s room, then you will be meeting with an independent, and clever young Escorts Service in Chanakyapuri committed to suit you an incredible social and suggestive experienceThe availability of Top Escorts Service in Chanakyapuri and other forms of Escorts, such as those associated with VIPs, makes it a popular choice amongst those who cannot afford their companion. Escorts Service in Chanakyapuri For Booking of Escorts Service in Chanakyapuri Delhi. Each and every detail that I have narrated here about my bodily assets is fully authentic and reliable We attempt the best Prostitutes in Chanakyapuri to be capable it give you the best assistance from our Escorts Service in Chanakyapuri. We have each sort of the young lady that can give you harmony and body love when you will invest enough energy with that young lady. But at the end of the day, human behavior is unpredictable and often goes against the tenets of probity and established norms. In this article, we will be delving a bit deep into the world of Escorts Service in Chanakyapuri

    ReplyDelete
  7. If you are searching for Best Carpet cleaning companies in perth you are at the right place. We are providing the Best House Cleaning Services in Perth. Our team provides the very best cleaning solutions, all at fantastic prices. Visit our website to learn more!

    ReplyDelete
  8. If you’re looking cleaning services in Perth, then End of Lease Cleaning Service in Perth is the answer. Carpet cleaning Perth .End of Lease Cleaning Perth offer fixed priced bond cleans and end of lease cleaning services. We offer professional End of lease cleaners in Perth.

    ReplyDelete
  9. Online PDF to Word converter free to convert documents online, Upload your file and transform it into Word in one click. Convert your Doc and Docx right now into Word and PDF format. Visit our Website!

    ReplyDelete
  10. App Dev Zone providing you many leading services, one way For All Design, to meet the marketing needs and Development. Including Logo Design, SEO services (SEO booster), WordPress Website Design and Hosting in all over World. Visit our Website to learn more!

    ReplyDelete
  11. HH Floor Sanding Perth provides all floor sanding services perth including restoration, staining, finishing and repair services, in all other Suburbs of Western Australia. We are a professional floor sanding company. Call 0411 151 555 for dust-free floor sanding services.

    ReplyDelete
  12. At Filhaal, we aim to provide traditional attire and accessories of all types to Pakistani females including small girls, teenagers, adults and even old ladies in an easy and fast way. The best thing about us is that we are unbeatable when it comes to price and quality. We feel proud to announce that we provide you with the dresses of your choice on the most competitive prices all over the UK. Visit our website to learn more!

    ReplyDelete

  13. Storevela is a blog that guides people to buy the top and best product they need by giving them reviews, information and stats about the particular.The best products for you to buy, We provide Buyer's Guides and comparison between different products. Visit our website to learn more!
    https://storevela.com/

    ReplyDelete
  14. Zainab Chottani Tahra Prints 2021 Collection is an exclusive collection of clothes designed by Zainab Chottani for House of Faiza.

    ReplyDelete
  15. We are a team of professionals that are very keen on providing honest reviews about gaming laptops and accessories. We are working our best to make your purchase long-lasting and reliable. All the reviews on our site are totally genuine and neutral, we never favored any brand or product by our own will. All the reviews are based on deep research and analysis. Visit our website to learn more!

    ReplyDelete
  16. Sky Remote TV is one of the most popular satellite TV providers in the world. Sky Remote TV also has its own line of remotes that are used to control your television.

    ReplyDelete
  17. Additionally, you can make a booking anytime of the night or day we make it easy to make it easy for you to book the most desirable models for your special occasion in rudrapur. With our 24/7 operating hours, it won't matter when you decide to meet with one of our models. You'll also have an enjoyable and stimulating time thanks to our fantastic models. They won't be missed in a flash.
    what's app Udaipur girls number
    phone call udaipur girls
    hot call udaipur girls number.
    call udaipur girls phone number
    call udaipur girls phone number

    ReplyDelete
  18. I will set up the whole thing for you with the purpose that you will have the nice pleasure of desirous adoration in an undistributed organic system. My incredible delight is to make my folks fulfilled and upbeat. This has helped me get a huge collection of nice in elegance gentlemen and industrialists as my rehash clients.
    what's app Dehradun girls number
    what's app dehradun girls phone
    phone call Nainital girls
    hot call Haldwani girls number.
    call Ramnagar girls phone number
    call Rudrapur models phone number
    call Rishikesh models phone number

    ReplyDelete
  19. You are doing a good work plz keep it up Thanks

    ReplyDelete
  20. best bizz is the UK most trusted website which provide list of leading businesses in the UK.Improvement agency, assisting with growing your business to be more profitable, sustainable and successful.. Visit our website to learn more!

    ReplyDelete
  21. Universal Cleaning Services is a privately owned cleaning company which always believed that the best way to service our clients' needs is to adopt and encourage a very high profile visible presence from all levels within our company. Our services are available 2 hours per day, 7 days a week, 52 weeks per year. Visit our website to learn more!

    ReplyDelete
  22. When looking for a girl, it's important to choose the right place. Islamabad is a city that is filled with bars and clubs, so there is a good chance that you'll find one in this city.

    ReplyDelete
  23. Are you a business owner in the UK? If so, you know about Gumtree and How it helps your UK business. Learn how to use Gumtree to promote your business and increase sales.

    ReplyDelete
  24. Thanks for Sharing Outstanding Informative post,
    I have really enjoyed and happy after reading this blog.

    ReplyDelete

Search This Blog