Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default opening page to Area's action

I have the project structure (see below). When I launch the project I get this error (see below). Could you tell me the change I have to do, I'd like when I start the project go to MyAreas1\Home

Thanks,

Error message : The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

enter image description here

like image 797
Kris-I Avatar asked Dec 27 '11 13:12

Kris-I


People also ask

Which of the following is a type of view in MVC?

On basis of data transfer mechanism ASP.NET MVC views are categorized as two types, Dynamic view. Strongly typed view.

Which is the startup page in MVC application?

Right-click your Project within the Solution Explorer. Choose Properties. Select the Web tab on the left-hand side. Under the Start Action section, define the Specific Page you would like to default to when the application is launched.

Which of the following is a default route pattern in MVC?

The Default route maps the first segment of a URL to a controller name, the second segment of a URL to a controller action, and the third segment to a parameter named id. The Default route maps this URL to the following parameters: controller = Home. action = Index.


2 Answers

You must set specified routing in Global.asax file

routes.MapRoute(
                "Default", // Route name
                "MyArea1/{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults

So what you need is to edit your default route.

like image 92
Chuck Norris Avatar answered Oct 11 '22 22:10

Chuck Norris


Try right click on the project >> properties>> Web>> now check Specific Page option and type the controllerName/ActionName

like image 29
HaBo Avatar answered Oct 11 '22 23:10

HaBo