using System.Web;
using System.Web.Mvc;
namespace MvcApplication2.Controllers
{
public 开发者_开发技巧class PersonController : Controller
{
//
// GET: /Person/
//string fname { get; set; }
//string lname { get; set; }
public string Index()
{
return "This is the first";
}
public string welcome()
{
return "welcome";
}
}
}
i have created a personcontroller and wrote the above coding. when i run the program it alwasy give the asp.net mvc2 default page. how can i set my personcontroller as my start page ?
You need to change the routes in your Global.asax.cs. You will need a route like this if you want the index action to the be the default route.
routes.MapRoute( "Web.Default", "{controller}/{action}/{id}", new { controller = "Person", action = "Index", id = "" });
If you want the default action to be welcome
then you can use this.
routes.MapRoute( "Web.Default", "{controller}/{action}/{id}", new { controller = "Person", action = "welcome", id = "" });
精彩评论