3

I have an ASP.net project I'm working on (1st time in ASP.net) however I'm curious to know how I would find which page is the page Visual Studio launches when I start debugging. Each time I search for this answer all the results simply tell you how to SET the startup page and not what the startup page actually IS. Basically - "What is the entry point"?

Currently my 'Start Action' when viewing the Project Properties is set to 'Current Page'. While I realize I can set a specific page or 'Start URL' I'm wondering what does 'Current Page' refer to? Basically I'm looking to know where I find the first line of code that is run when I begin debugging.

My initial thought was that it is looking for an aspx file named default.aspx but since my project has two of these files named default.aspx I guess it's pointing to the one residing with my other project files that sit at the root of my project.

Is this correct?

enter image description here

Code Novice
  • 2,043
  • 1
  • 20
  • 44
  • 1
    You can find the Default page by checking your routes. If you truly have an MVC app you should have somewhere a static class called RouteConfig. This will have a route setup with a controller/action pair. – cvb Apr 10 '19 at 21:37

1 Answers1

4

I think there is two question you are asking.

Firstly, where is the entry point for your MVC application? Well your entry point for debugging MVC application would be Application_Start in Global.asax.cs file

protected void Application_Start()
{

}

Secondly, the Start Action is Visual Studio enables you to specify what happens when you run your application.

  • Current Page – Enables you to run the page currently open for editing in Visual Studio.

  • Specific Page – Enables you to set a particular page to run. You can set the page here or you can right-click a page in the Solution Explorer window and select the menu option Set As Start Page.

  • Start External Program – Enables you to run an external program.
  • Start URL – Enables you to request a URL. This option is typically used when building a Web Services application.
  • Don’t open a page – Enables you to do nothing.

You can change the start page to a particular page. For example, if you want to request the URL /Blog/Show/23 when your application starts, then you can enter this URL into the Specific Page input field.

Hasta Tamang
  • 2,205
  • 1
  • 18
  • 17
  • Perhaps I'm confused as to what an MVC ASP.net application is. I say this due to my not seeing any files named `Global.asax.cs`. In fact I don't have any files with asax extensions. My Project does however have a Web.config file. I found this link that seems to be closer to my existing setup: https://stackoverflow.com/questions/307821/what-alternatives-are-there-to-using-global-asax. – Code Novice Apr 10 '19 at 21:22
  • 1
    I answered in MVC as the question was tagged as MVC, if this is not the case let me know which? If it is a default MVC application you should have a Gloabal.asax file. You can test it yourself by creating a new web application and selecting MVC. – Hasta Tamang Apr 10 '19 at 21:34
  • Good to know. Since I did not create the project I'm not sure how to see in Visual Studio what the original project was that was created for the project I'm now working on. I know that it's ASP.net due to it using the namespaces System.Web. I thought the project was MVC due to it organizing it's code into the MVC architecture. I see ViewModels folder and a Models folder. All of the data that is being gathered by the code behind written in c# is being bound to from the aspx aka ASP.net code. Is my assumption wrong? It looks like MVC. – Code Novice Apr 12 '19 at 15:45
  • 1
    Under References check if you have `System.Web.MVC`. Since you had mentioned `Default.aspx` I believe it is a WebForm project. – Hasta Tamang Apr 12 '19 at 16:51
  • I do not have that reference. I guess maybe that this project was created as an ASP.net Web Forms. – Code Novice Apr 12 '19 at 18:14