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

38 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. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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

  11. 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
  12. Zainab Chottani Tahra Prints 2021 Collection is an exclusive collection of clothes designed by Zainab Chottani for House of Faiza.

    ReplyDelete
  13. 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
  14. 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
  15. 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
  16. You are doing a good work plz keep it up Thanks

    ReplyDelete
  17. 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
  18. 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
  19. 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
  20. Thanks for Sharing Outstanding Informative post,
    I have really enjoyed and happy after reading this blog.

    ReplyDelete
  21. Thank you for sharing the outstanding and very useful information. Keep it up

    ReplyDelete
  22. Elinko is a great blogging website sharing latest news, reviews, & info about multiple topics e.g. Business, Technology, Health & Fittness, Shopping etc. Discover the UK’s Best Businesses & Agencies

    ReplyDelete
  23. Pro Sofa Clean is one of the most professional sofa and couch cleaning companies in Sydney. We aim to extend the life of your old domestic, office and commercial sofa or couch by cleaning it to look and feel good as new. Visit our website to learn more!

    ReplyDelete
  24. Get Same Day Sofa Cleaning Parramatta NSW at Your Doorstep. Pro Sofa Cleaning Parramatta Offer best steam Couch Cleaning & Upholstery cleaning Parramatta Sydney. Call now for Sofa Cleaner booking.

    ReplyDelete
  25. Find here Couch Cleaning Sydney, L-shaped Couch Steam Cleaning, and Round Couch Cleaning in Sydney. Pro Sofa Clean offers professional couch cleaning across Sydney. Call us for Couch stain removal, Couch steam cleaning, and Couch marks removal in Sydney.

    ReplyDelete
  26. Need same day sofa cleaning Kogarah today? You are at the right place. Pro Sofa Clean offers doorstep suede cleaning Kogarah and couch cleaning services today.

    ReplyDelete
  27. This blog is so good, such a nice post , thanks for sharing it with us.

    ReplyDelete
  28. Chord Buzz is our blog is your passport to a world of information and ideas. Join us in exploring everything from art to science, all under one digital roof.

    ReplyDelete
  29. Display cleaning is significant because that dirty windows can damage the charm and charm of one’s premises. Specifically, if you end up living inside your home that is simply not in a tree floor it is recommended for yourself to hire professionals in the cleaning in windows. Because the equipment and tools are designed for the competent cleaner to remain himself dependable from accidental injuries.

    ReplyDelete
  30. Musharaf nazar
    My self Musharaf Nazar from chunian and i'm a digital marketer
    lavar.com

    ReplyDelete
  31. This article presents advice, techniques, and insights to win your husband back . Remember that each condition is distinctive, and there are no guarantees. But you have to clear the way for a likely reunion with the help of tolerance, understanding, and dedication.

    ReplyDelete
  32. "Movers and packers in Karachi" refer to professional service providers in Karachi, Pakistan, who specialize in assisting individuals and businesses with the relocation of their belongings. These companies typically offer a range of services, including packing items securely, loading and unloading, transportation, and unpacking at the new location. The goal is to make the moving process smoother and less stressful for clients by efficiently handling the logistics of their move. These services are particularly valuable for those moving houses, offices, or businesses within Karachi or to other locations. Choosing reliable movers and packers can ensure a hassle-free and organized moving experience.






    ReplyDelete

  33. Movers and packers are professionals or companies that offer relocation services to individuals or businesses. Their primary function is to assist people in the process of moving from one location to another, whether it's within the same city or to a different region.

    ReplyDelete
  34. Aya Hitakayama lifestyle has become a topic of fascination for people worldwide, thanks to her distinctive choices that set her apart from the crowd.

    ReplyDelete
  35. Kristal Bold has earned a reputation as the ultimate choice for discerning fashion enthusiasts. This portion examines the factors that make it a preferred brand among fashion connoisseurs

    ReplyDelete
  36. We have a rich history rooted in practicality and durability. Tracing their origins back to the 19th century, denim dresses were initially designed for workwear, owing to the fabric’s robust nature.

    ReplyDelete
  37. New hairstyle trends emerge every year, and prom-goers eagerly look for the latest styles to make a statement on their special night. In 2024, some hottest prom hairstyles trends include sleek low buns, romantic curls, and chic ponytails.

    ReplyDelete

Search This Blog