0

I am new to MVC.I have some doubts.

1) My MVC Application contains

 i)Default.aspx



   ii)Views
          ... Home
                    ... About.aspx
                    ... Index.aspx

during execution which one will load first Default.aspx ? or About.aspx?

2) I want to display a webpage that lists menu items (LinkButtons)as start page.For that do i need to design a View or web page ?

5 Answers 5

2

First, I would suggest reading up on how the Model-View-Controller pattern works.

To answer your questions:

  1. The Default.aspx file is for older versions of IIS that require a default document to start the ASP.NET MVC handler. IIS7 does this with a mapping in web.config. So, when you visit your MVC application, whichever route is configured as the default will load first. The .aspx files in the Views folder are, of course, your views. The content of these get returned by controller actions.

  2. ASP.NET MVC uses views, but I don't think there's anything preventing you from placing a plain old .aspx page somewhere. I wouldn't recommend it, though, because it's best to stick to the MVC pattern (that's what ASP.NET MVC is all about, after all). If you want to display your menu in more than one place, I would suggest a "partial view". If you want to display your menu on all pages, place it in a "master page".

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Default.aspx is instrumented to allow routing. Don't remove it, but it won't actually display. The default route (as defined in Global.asax.cs) will be /home which translates to the index action on the home controller.

  2. Simply change the index view for the home controller. It is already set up as your "start" page.

Comments

0

1) Depends on the routes define in global.asax but by default the Home controller and the index action will return index.aspx

2)You cam mix web forms and MVC but it's better to just stick with MVC unless you have good reason, so you should use a view,

You should head over to the mvc site, there are many good tutorials and examples.

Comments

0

i think you should start reading asp.net mvc book first.

for

  1. default.aspx
  2. whatever you like... but its upto you how you use it.....

Comments

0
public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Account", action = "LogOn", id = UrlParameter.Optional } // Parameter defaults
        );

    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterRoutes(RouteTable.Routes);
    }

that is the code in global.asax file and it tells your default route to the application as for your default it will be like your controller is Home and your action is Index for mine when i just debug and start the application it will first call the Application_start method and then the next code of RegisterRoutes appears... where you put maproute method and you navigate to the application

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.