Tech Junkie Blog - Real World Tutorials, Happy Coding!: End-to-End ASP.NET MVC : Create an ASP.NET MVC Empty Project

Saturday, June 18, 2016

End-to-End ASP.NET MVC : Create an ASP.NET MVC Empty Project

A lot of people think that you can only create one kind of ASP.NET MVC  project, the one with the sample application.  But the reality is that you can create an Empty ASP.NET MVC, you just need to do more work.  However, it is cleaner and you can add what you need, instead of having everything in place already like the default template.  So you might run into more errors with the empty project, but I think you will learn more about MVC than if you just have the default template.  Plus it's more streamline.  I always start with an empty project on my MVC projects.  In order to follow this tutorial you must have Visual Studio 2017 installed.


Step-By-Step Instructions:
  1. Create a new project in Visual Studio call "NorthwindCafe", by clicking on File → New → Project
  2. Select Visual C# → Web → ASP.NET Web Application, in the "Name:" field type the name "NorthwindCafe", then click "OK"


 3.  On the next screen select "Empty" on the "Select a template" menu, then under "Add folders and core references for:", check the "MVC" checkbox.


 4.  Your empty ASP.NET MVC  project is created in Visual Studio 2017


5.  We are not done yet,  since this is an empty project we will get an error if we try to run the application.  Hit "Ctrl+F5" to run the application.  You will get this message



Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3056.0

The reason you are getting a 404 error is because there's no "Controller" or "View" to browse to.  Since we just created a bare bones ASP.NET MVC  project.

6.  So to get the application to run we will create a simple Controller and View in the MvcApp project.

7. Right click on the "Controller" folder and select "Add" → "Controller"



8.  On the "Add Controller" screen type "HomeController" on the "Controller name" text box and select "Empty MVC controller".  We just want to keep things simple for this blog.  Then click "Add"





9.  You see the "HomeController.cs" class being added to the "Controllers" folder

HomeController configuration

10.  Double click on the "HomeController.cs" file and you will see the following code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NorthwindCafe.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

    }
}


11.  Right click on the "Index()" method and select "Add View"

Add View To Index method








12.   Uncheck the "Use a layout or master page" checkbox. Accept the default settings, MVC uses conventions so the view has the same name as the method name in the "HomeController.cs" file which is "Index()", then click "Add"




13.  In the "Views" folder you see that the "Home" folder has been created with the view "Index.cshtml", the .cshtml extension means that the view uses the C# syntax.


14.  Double click on the view "Index.cshtml" and type "Hello World" between the <div> tag like the markup below

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        Hello World!
    </div>
</body>
</html>

15. Press Ctrl+F5 to run the application, you will see the following.

Browse Hello World View












16.  Now that we have a working empty ASP.NET MVC project, we need add the items to the projects using NuGet.


Similar Posts:


                                                                                               Next: ASP.NET : Add jQuery Library Using NuGet
           

277 comments:

  1. Hello,

    I followed your tutorial step by step I still get The resource cannot be found.

    I don't know what seems to be the problem.

    I am using VS express 2012 but I have added the plugin to use MVC5 so I created an epmty mvc5 project

    Thanks

    ReplyDelete
  2. What step are you stuck on? I used Visual Studio 2013 the full version so the steps might be a little different.

    ReplyDelete
  3. Actually I think I was using Visual Studio Community Edition 2013 you can get it here at https://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx

    ReplyDelete
  4. Hello,

    I have the same problem of Sabrine Azouz, in the step 15 when trying to run the application, get the resource cannot be found error

    ReplyDelete
  5. I had the same trouble, but it went away when I restarted Visual Studio. I'm using VS2015 community, and everything works fine. Thanks Jason, great article.

    ReplyDelete
  6. Thank you so much for writing this. I have been looking for a long time for a set of tutorials that starts without everything auto-installed, allowing you to add things as you need them so you understand what's going on. This is fantastic.

    ReplyDelete
  7. Thanks for this. It was really helpful!

    ReplyDelete
  8. Hey, I just wanted to mention that these instructions worked perfectly using Monodevelop 5.10 on a Fedora 23 box. The only deviation from these instructions that I had to do was to create a registry directory. Like so...

    sudo mkdir /etc/mono/registry
    sudo chmod uog+rw /etc/mono/registry/

    Thanks for your efforts in putting together this tutorial!

    ReplyDelete
    Replies
    1. I'm using Debian 8.x and the directory already exists.

      Thanks!

      Delete
  9. Thanks I've been looking for good tutorial that would start from scratch. Most of the books I see use MVC template..

    ReplyDelete
  10. Thank u so much. Explained in such a easy and simple way. Really helpful.

    ReplyDelete
  11. I am using vidual studio 2015.I have created mvc empty web application.
    I have created 2 webpages in aspx.also created controller for both.
    when i buld the project one page gets loaded successfully in browser.

    On click of a buuton on one page second page shuld be loaded.like anchor tag does in html.
    Can you help me with that?

    ReplyDelete
    Replies
    1. I would recommend that you remove the .aspx page. Since this is an MVC application and razor is the view template that Microsoft is pushing. It would make your life a lot easier if you stick with razor

      Delete
  12. thanks dude. I was going bonkers trying to get a simple asp.net one page mvc website running. This got me going in the right direction

    ReplyDelete
  13. Really excellent tutorial gives very in-depth picture how actually thing works sir

    ReplyDelete
  14. This comment has been removed by a blog administrator.

    ReplyDelete
  15. This comment has been removed by a blog administrator.

    ReplyDelete
  16. Very Nice blog. Really helpful information about ASP …. Please keep update some more…………

    ReplyDelete
  17. nicely explain the process to create mvc project

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Well done, man.
    It wasn't easy to find the answer for a new developer in ASP as miself.

    ReplyDelete
  20. This comment has been removed by a blog administrator.

    ReplyDelete
  21. This comment has been removed by a blog administrator.

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Best UIPath Robotic Process Automation Course Training Institute in kanchipuram|

    ReplyDelete
  24. It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
    RPA Training in chennai |RPA Training course chennai

    ReplyDelete
  25. Useful information Thank-you for sharing. really helpful keep sharing your views. Please visit link mentioned below and share your views on them.
    best hvac training in lucknow
    job oriented training institute in lucknow
    best php training in lucknow
    digital marketing training in lucknow

    ReplyDelete

  26. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top microservices online training

    ReplyDelete
  27. If u are looking for Management Assignment Help visit at essaycorp.com.au. we provide Management Assignment Help across the world at very affordable prices.
    Management Assignment Help

    ReplyDelete
  28. Awesome.....Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
    Please do visit my website hope you'll like it: http://oceaninfosystem.com/
    Best software development company in Lucknow
    Best summer training company in Lucknow
    Best MLM company in Lucknow
    Best software development company
    Best summer internship institute Lucknow

    ReplyDelete
  29. Awesome.....Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
    Please do visit my website hope you'll like it: http://oceaninfosystem.com/
    Best software development company in Lucknow
    Best summer training company in Lucknow
    Best MLM company in Lucknow
    Best software development company
    Best summer internship institute Lucknow

    ReplyDelete
  30. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! Emma

    ReplyDelete
  31. You might be astonished to become familiar with a portion of these reasons truly bode well. Find more here

    ReplyDelete
  32. Great Article. Thank-you for such useful information. I have read many of your post and this post is wonderful....
    http://pihmct.com/
    Best hotel management college
    Top hotel management college
    Best hotel management college near me
    diploma in hotel management
    Best hotel management institute
    Best institute for hotel management
    Get trained by professional and build your career in top Multi-national companies.

    ReplyDelete
  33. I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. devops online training

    ReplyDelete
  34. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    best workday studio online training
    top workday studio online training
    workday studio online training

    ReplyDelete
  35. Informative blog. Thanks for sharing, this post is wonderful....all of your posts are just awesome. Please do visit my website hope you'll like it:
    Best trust in Lucknow
    Best NGO in Lucknow
    Best social worker in Lucknow
    Social worker in Lucknow
    Best govt. health scheme in Lucknow
    NGO in Lucknow

    ReplyDelete
  36. This comment has been removed by the author.

    ReplyDelete
  37. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    workday studio online training
    best workday studio online training
    top workday studio online training

    ReplyDelete
  38. We as a team of real-time industrial experience with a lot of knowledge in developing applications in python programming (7+ years) will ensure that we will deliver our best in python training in vijayawada. , and we believe that no one matches us in this context.

    ReplyDelete
  39. I find this blog to be very interesting and very resourceful. I would say that your blogs are really interesting and informative for me and this article explained everything in detail.
    Best pathology in lucknow
    Best pathology in jankipuram
    Diagnostic centre in lucknow
    X-ray pathology in jankipuram
    Best diagnostic centre in lucknow
    Pathology centre in jankipuram

    ReplyDelete
  40. Playing out this activity will truly limit your inquiry and will disentangle your procedure when the opportunity arrives to genuinely go out for looking through land properties.
    real estate

    ReplyDelete
  41. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    microservices online training
    best microservices online training
    top microservices online training

    ReplyDelete
  42. I just loved your article on the beginners guide to starting a blog. Thank you for this article. devops training online Online and devops tutorial videos with highly experienced facutly.

    ReplyDelete
  43. These estimates do not automatically take into account property remodels or renovations or other property specific or local changes. parc botannia

    ReplyDelete
  44. This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post! arlo camera

    ReplyDelete
  45. Very informative post ….Thanks for sharing. Learned a lot of things about trust flow and citation flow. Keep up the good work.
    espn.com/activate
    xfinity.com/authorize

    ReplyDelete
  46. The worst part of it was that the software only worked intermittently and the data was not accurate. You obviously canot confront anyone about what you have discovered if the information is not right. selling oakville homes

    ReplyDelete
  47. Hello Admin!

    Thanks for the post. It was very interesting and meaningful. I really appreciate it! Keep updating stuffs like this. If you are looking for the Advertising Agency in Chennai | Printing in Chennai , Visit Inoventic Creative Agency Today..

    ReplyDelete
  48. An internship planning is presumably the most obvious opportunity to increment sensible data.internship in chennai for mechatronics is a brief position is the best spot to get acquainted with a lot of information related to practical more than the theoretical.

    ReplyDelete
  49. ASP.NET is completely top trending course. #AWS is also the Top in Cloud technology.

    Aws course in Hyderabad
    Best aws training in Hyderabad

    ReplyDelete
  50. We as a team of real-time industrial experience with a lot of knowledge in developing applications in python programming (7+ years) will ensure that we will deliver our best inpython training in vijayawada. , and we believe that no one matches us in this context.

    ReplyDelete
  51. CodeGnan offers courses in new technologies and makes sure students understand the flow of work from each and every perspective in a Real-Time environment.
    python training in vijayawada.
    data science training in vijayawada.

    ReplyDelete
  52. CodeGnan offers courses in new technologies and makes sure students understand the flow of work from each and every perspective in a Real-Time environment.
    python training in vijayawada.
    data science training in vijayawada.

    ReplyDelete
  53. Its really great being a content writer I can understand how tough is it to write and develop the content ,Thanks for sharing this wonderful informationSAP Training in Lucknow 
    Digital marketing training in Lucknow 
    AUTOCAD Training in Lucknow  
    PYthon Training in Lucknow  
    SAP FICO Training in Lucknow  

    ReplyDelete
  54. Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
    SEO Training in Chennai
    SEO Course in Chennai
    SEO Training Institute in Chennai
    SEO Classes in Chennai
    Best SEO Training in Chennai

    ReplyDelete
  55. Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
    SEO Training in Bangalore
    SEO Course in Bangalore
    SEO Training Institute in Bangalore
    Best SEO Training Institute in Bangalore
    SEO Training Bangalore
    SEO Training in Madurai
    SEO Training in Coimbatore
    SEO Course in Coimbatore
    SEO Training Courses in Coimbatore

    ReplyDelete
  56. This is a wonderful article, Given so much info in it, Thanks for sharing. CodeGnan offers courses in new technologies and makes sure students understand the flow of work from each and every perspective in a Real-Time environmen python training in vijayawada. , data scince training in vijayawada . , java training in vijayawada. ,

    ReplyDelete
  57. This is a wonderful article, Given so much info in it, Thanks for sharing. CodeGnan offers courses in new technologies and makes sure students understand the flow of work from each and every perspective in a Real-Time environmen python training in vijayawada. , data scince training in vijayawada . , java training in vijayawada. ,

    ReplyDelete
  58. i-LEND is an online marketplace connecting borrowers and lenders for loans. Although i-LEND verifies credentials of registered users on the site, it does not guarantee any loan offers by lenders nor does it guarantee any repayments by borrowers. Users make offers/loan requests at their own discretion with the understanding of the risks involved in such transactions including loss of entire capital and/or no guarantee of recovery. Please read our Legal agreements to understand more. borrow money

    ReplyDelete
  59. hello sir,thanks for giving that type of information...This page contains all the active and recently expired job openings and recruitment notification from India Postal Recruitment 2020...

    ReplyDelete
  60. it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. top realtors in oakville

    ReplyDelete
  61. Nice to see this BLOG..keep updating More infromation Digital Lync offers one of the best Full Stack training in Hyderabad with a comprehensive course curriculum with Continuous Integration, Delivery, and Testing. Elevate your practical knowledge with quizzes, assignments, Competitions, and Hackathons to give a boost to your confidence with our hands-on Full Stack Training.
    web development courses
    full stack developer course
    full stack developer course in hyderabad
    web development courses in gachibowli
    front end developer course
    full stack developer course with placement

    ReplyDelete
  62. Nice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
    Digital Marketing Course In Kolkata
    Web Design Course In Kolkata

    ReplyDelete
  63. Second Innings Home is the first and only premium home & health care service in India. Second Innings Home proposed across the nation features a beautiful campus ideally located in a well-maintained gated community in the format of a Star Hotel with luxurious amenities. It’s convenient to enjoy the privacy and to be near the city and nearby facilities. And yet it retains a sense of community spirit and the warmth of a small community. good retirement homes in Hyderabad

    ReplyDelete
  64. Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
    SEO Training in Chennai
    SEO Course in Chennai
    SEO Training Institute in Chennai
    SEO Classes in Chennai
    Best SEO Training in Chennai

    ReplyDelete
  65. KloudWIFI truly believes that reliable, fast networks have been the game changers in driving innovation, productivity and instant collaboration supported by the relentless growth of convenient cloud-hosted applications. Even with a powerful, proven network infrastructure like Cisco Meraki and Ekahau, the end user experience can only be truly optimized by considering all the internal and external factors to the end user experiences. meraki insight partner in hyderabad

    ReplyDelete
  66. workday online Make yourself an expert and be trained with our high professional trainers for workday HCM online training provided by Evantatech.

    ReplyDelete
  67. Hello, everyone! I,m here to explore blogs and forum about the wonderful and most safe cure for (Herpes Virus).I was positive to the deadly virus called herpes and i lost hope because i was out casted and rejected even by my closet friends.i searched on-line to know and enquirer about cure for Herpes and i read someone testimony  i know that nature has the power to heal everything.i contacted him to knoon how he was cured from Herpes so i decided to contact the same herbalist becausew how he can help me and he told me never to worry that he will heal me with the natural herbs from God!after 2 days of contacting him, he told me that the cure has been ready and he sent it to me via DHL and it got to me after 3 days!i used the med as he instructed me (MORNING and EVENING) and i was cured!its really like a dream but i am so happy!thats the reason i decided to also add more comment of Him so that more can be saved just like me!and if you need his help, you can email him on (drakuzasolutioncenter@gmail.com) : whatsapp+2348072437003 I,m neme amber and you can get in touch with Contact him for help at Herpes virus HIV/AIDS CANCER COPD BRAIN TUMOR All kind of virus and disease.....

    ReplyDelete
  68. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. RARBG

    ReplyDelete
  69. Awesome post! This is helpful post. Article is very clear and with lots of useful information. Thanks for such nice article
    Visit : https://pythontraining.dzone.co.in/training/data-science-training.html

    ReplyDelete
  70. I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon… Claremont real estate agents

    ReplyDelete
  71. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page! Real estate agency claremont

    ReplyDelete
  72. Wonderful article! Technology We will be linking to this particularly great content on our site. Keep up the good writing.

    ReplyDelete
  73. Just wanna say a big thank you patrice cythia for introducing me to Dr Idedia the great HERBALIST that helped me prepare home remedies that cured my herpes simplex virus (HSV1&2)
    I was infected with herpes for the past two years and i was not happy all day so i was desperate to get a cure so that i can live normal and get healthy.One day i was less busy so i decided to make latest research on herpes  cure  and i found a site were everyone was talking about Dr Idedia and has ability to cure Herpes, HIV, HPV, Cancer, ALS, COPD, Anthrax, genital wart, cold sore, Arthritis skin tag and all manners of diseases and virus.So i discussed with cythia and she explained to me that its very easy working with Dr Idedia  so i contacted Dr Idedia via email  dr.idediatraditionalhealinghome@gmail.com and he helped me just as he has helped others now I am  now cured from herpes am very happy now.and i can also assure you that he can also help you. so if you need the service of DR Idedia kindly contact him dr.idediatraditionalhealinghome@gmail.com or whatsapp +2349074505296.
    visit his websites  https://dr-idedia-traditional-healing-home9.webnode.com/ Or https://sites.google.com/view/dridediatraditionalhealinghome/ Or https://dr-idedia-traditional-healing-home.business.site/ 

    ReplyDelete
  74. The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface. flat fee mls chicago

    ReplyDelete
  75. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    servicenow online training
    best servicenow online training
    top servicenow online training

    ReplyDelete
  76. Are you wishing to purchase the best work socks for sweaty feet ? Well, everyone desires to buy because bb guns are the best for Airgun sports. People use these guns for target practice and training.

    ReplyDelete
  77. Are you wishing to purchase the Best BB Guns for beginners? Well, everyone desires to buy because bb guns are the best for Airgun sports. People use these guns for target practice and training.

    ReplyDelete
  78. Are you searching for the Gaming Laptop under 2000? ? Gaming is the most joyful activity that people perform in their spare time. The gamers have their PC for playing multiple games.

    ReplyDelete
  79. Are you wishing to buy a Best Cheap Tablet with Stylus ? ? ? There are multiple tablets available for a cheap and affordable price throughout the Internet.

    ReplyDelete
  80. HOW I GOT RID OF MY HERPES Virus WITH THE HELP OF DR AKERE.    Greetings to the general public, i want to inform the general public how i was
    cured of HERPES Simplex Virus by a Doctor called Dr AKERE. i visited different hospital but they gave me list of drugs like Famvir, Zovirax, and is Valtrex which is very expensive to treat the symptoms and never cured me. I was browsing through the Internet searching for remedy on HERPES and i saw comment of people talking about how Doctor Dr AKERE cured them. when i contacted him he gave me hope and send a Herbal medicine to me that i took as instructed and it seriously worked for me, i am a free person now without problem, my HERPES result came out negative. I pray for you Dr AKERE God will give you everlasting life, you shall not die before your time for being a sincere and great man. Am so happy, you can also contact him if you have any problem like HIV/AID, CANCER,HERPATITIS,DIABETES,HPV,INFECTION ETC. Reach him on his  Email Address at=== drakereherbalcure@gmail.com  or you can contact him on WHATSAPP FOR EASY ACCESS at +2348070670337 you can visit his website at https://drakereherbalcure.wixsite.com/website-2 blog: 


    https://drakereremedy.blogspot.com/ here is where you can also visit his facebook page https://m.facebook.com/drakereherbalremedy/ DR AKERE is indeed i true healer and a great man

    ReplyDelete
  81. Everyone wishes to pass on a Largest Android Tablets? with them. Nevertheless, the greatest screen tablets are not conveniently found. Tablets are the hugest electronic device that people like to pass on.

    ReplyDelete

Search This Blog